home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / gnumans.zip / gdb.inf (.txt) < prev    next >
OS/2 Help File  |  1997-07-02  |  270KB  |  8,289 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Title page ΓòÉΓòÉΓòÉ
  3.  
  4.                                Debugging with GDB
  5.  
  6.                           The gnu Source-Level Debugger
  7.  
  8.                        Edition 4.12, for GDB version 4.16
  9.  
  10.                                   January 1994
  11.  
  12.                       Richard M. Stallman and Cygnus Support
  13.  
  14. Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995 Free Software 
  15. Foundation, Inc. 
  16.  
  17. Published by the Free Software Foundation 
  18. 59 Temple Place - Suite 330, 
  19. Boston, MA 02111-1307 USA 
  20. Printed copies are available for $20 each. 
  21. ISBN 1-882114-11-6 
  22.  
  23. Permission is granted to make and distribute verbatim copies of this manual 
  24. provided the copyright notice and this permission notice are preserved on all 
  25. copies. 
  26.  
  27. Permission is granted to copy and distribute modified versions of this manual 
  28. under the conditions for verbatim copying, provided also that the entire 
  29. resulting derived work is distributed under the terms of a permission notice 
  30. identical to this one. 
  31.  
  32. Permission is granted to copy and distribute translations of this manual into 
  33. another language, under the above conditions for modified versions. 
  34.  
  35.  
  36. ΓòÉΓòÉΓòÉ 2. Top node: "Debugging with GDB" ΓòÉΓòÉΓòÉ
  37.  
  38. This file describes GDB, the gnu symbolic debugger. 
  39.  
  40. This is Edition 4.12, January 1994, for GDB Version 4.16. 
  41.  
  42.  Summary                                 Summary of GDBN 
  43.  
  44.  Sample Session                          A sample GDBN session 
  45.  
  46.  Invocation                              Getting in and out of GDBN 
  47.  Commands                                GDBN commands 
  48.  Running                                 Running programs under GDBN 
  49.  Stopping                                Stopping and continuing 
  50.  Stack                                   Examining the stack 
  51.  Source                                  Examining source files 
  52.  Data                                    Examining data 
  53.  
  54.  Languages                               Using GDBN with different languages 
  55.  
  56.  C                                       C language support 
  57.  
  58.  Symbols                                 Examining the symbol table 
  59.  Altering                                Altering execution 
  60.  GDB Files                               GDBN files 
  61.  Targets                                 Specifying a debugging target 
  62.  Controlling GDB                         Controlling GDBN 
  63.  Sequences                               Canned sequences of commands 
  64.  
  65.  Emacs                                   Using GDBN under gnu Emacs 
  66.  
  67.  GDB Bugs                                Reporting bugs in GDBN 
  68.  Command Line Editing                    Facilities of the readline library 
  69.  Using History Interactively 
  70.  
  71.  Formatting Documentation                How to format and print GDBN 
  72.                                          documentation 
  73.  Installing GDB                          Installing GDB 
  74.  
  75.  Index                                   Index 
  76.  
  77.  
  78. ΓòÉΓòÉΓòÉ 3. Summary of GDB ΓòÉΓòÉΓòÉ
  79.  
  80. The purpose of a debugger such as GDB is to allow you to see what is going on 
  81. ``inside'' another program while it executes---or what another program was 
  82. doing at the moment it crashed. 
  83.  
  84. GDB can do four main kinds of things (plus other things in support of these) to 
  85. help you catch bugs in the act: 
  86.  
  87.      Start your program, specifying anything that might affect its behavior. 
  88.  
  89.      Make your program stop on specified conditions. 
  90.  
  91.      Examine what has happened, when your program has stopped. 
  92.  
  93.      Change things in your program, so you can experiment with correcting the 
  94.       effects of one bug and go on to learn about another. 
  95.  
  96.  You can use GDB to debug programs written in C or C++. For more information, 
  97.  see C and C++. 
  98.  
  99.  Support for Modula-2 and Chill is partial.  For information on Modula-2, see 
  100.  Modula-2.  There is no further documentation on Chill yet. 
  101.  
  102.  Debugging Pascal programs which use sets, subranges, file variables, or nested 
  103.  functions does not currently work.  GDB does not support entering expressions, 
  104.  printing values, or similar features using Pascal syntax. 
  105.  
  106.  GDB can be used to debug programs written in Fortran, although it does not yet 
  107.  support entering expressions, printing values, or similar features using 
  108.  Fortran syntax.  It may be necessary to refer to some variables with a 
  109.  trailing underscore. 
  110.  
  111.  Free Software                           Freely redistributable software 
  112.  Contributors                            Contributors to GDB 
  113.  
  114.  
  115. ΓòÉΓòÉΓòÉ 3.1. Free software ΓòÉΓòÉΓòÉ
  116.  
  117. GDB is free software, protected by the gnu General Public License (GPL).  The 
  118. GPL gives you the freedom to copy or adapt a licensed program---but every 
  119. person getting a copy also gets with it the freedom to modify that copy (which 
  120. means that they must get access to the source code), and the freedom to 
  121. distribute further copies. Typical software companies use copyrights to limit 
  122. your freedoms; the Free Software Foundation uses the GPL to preserve these 
  123. freedoms. 
  124.  
  125. Fundamentally, the General Public License is a license which says that you have 
  126. these freedoms and that you cannot take these freedoms away from anyone else. 
  127.  
  128.  
  129. ΓòÉΓòÉΓòÉ 3.2. Contributors to GDB ΓòÉΓòÉΓòÉ
  130.  
  131. Richard Stallman was the original author of GDB, and of many other gnu 
  132. programs.  Many others have contributed to its development.  This section 
  133. attempts to credit major contributors.  One of the virtues of free software is 
  134. that everyone is free to contribute to it; with regret, we cannot actually 
  135. acknowledge everyone here.  The file `ChangeLog' in the GDB distribution 
  136. approximates a blow-by-blow account. 
  137.  
  138. Changes much prior to version 2.0 are lost in the mists of time. 
  139.  
  140. Plea: Additions to this section are particularly welcome.  If you or your 
  141. friends (or enemies, to be evenhanded) have been unfairly omitted from this 
  142. list, we would like to add your names! 
  143.  
  144. So that they may not regard their long labor as thankless, we particularly 
  145. thank those who shepherded GDB through major releases: Stan Shebs (release 
  146. 4.14), Fred Fish (releases 4.13, 4.12, 4.11, 4.10, and 4.9), Stu Grossman and 
  147. John Gilmore (releases 4.8, 4.7, 4.6, 4.5, and 4.4), John Gilmore (releases 
  148. 4.3, 4.2, 4.1, 4.0, and 3.9); Jim Kingdon (releases 3.5, 3.4, and 3.3); and 
  149. Randy Smith (releases 3.2, 3.1, and 3.0). As major maintainer of GDB for some 
  150. period, each contributed significantly to the structure, stability, and 
  151. capabilities of the entire debugger. 
  152.  
  153. Richard Stallman, assisted at various times by Peter TerMaat, Chris Hanson, and 
  154. Richard Mlynarik, handled releases through 2.8. 
  155.  
  156. Michael Tiemann is the author of most of the gnu C++ support in GDB, with 
  157. significant additional contributions from Per Bothner.  James Clark wrote the 
  158. gnu C++ demangler.  Early work on C++ was by Peter TerMaat (who also did much 
  159. general update work leading to release 3.0). 
  160.  
  161. GDB 4 uses the BFD subroutine library to examine multiple object-file formats; 
  162. BFD was a joint project of David V. Henkel-Wallace, Rich Pixley, Steve 
  163. Chamberlain, and John Gilmore. 
  164.  
  165. David Johnson wrote the original COFF support; Pace Willison did the original 
  166. support for encapsulated COFF. 
  167.  
  168. Adam de Boor and Bradley Davis contributed the ISI Optimum V support. Per 
  169. Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS support. 
  170. Jean-Daniel Fekete contributed Sun 386i support. Chris Hanson improved the 
  171. HP9000 support. Noboyuki Hikichi and Tomoyuki Hasei contributed Sony/News OS 3 
  172. support. David Johnson contributed Encore Umax support. Jyrki Kuoppala 
  173. contributed Altos 3068 support. Jeff Law contributed HP PA and SOM support. 
  174. Keith Packard contributed NS32K support. Doug Rabson contributed Acorn Risc 
  175. Machine support. Bob Rusk contributed Harris Nighthawk CX-UX support. Chris 
  176. Smith contributed Convex support (and Fortran debugging). Jonathan Stone 
  177. contributed Pyramid support. Michael Tiemann contributed SPARC support. Tim 
  178. Tucker contributed support for the Gould NP1 and Gould Powernode. Pace Willison 
  179. contributed Intel 386 support. Jay Vosburgh contributed Symmetry support. 
  180.  
  181. Rich Schaefer and Peter Schauer helped with support of SunOS shared libraries. 
  182.  
  183. Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about several 
  184. machine instruction sets. 
  185.  
  186. Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped develop remote 
  187. debugging.  Intel Corporation and Wind River Systems contributed remote 
  188. debugging modules for their products. 
  189.  
  190. Brian Fox is the author of the readline libraries providing command-line 
  191. editing and command history. 
  192.  
  193. Andrew Beers of SUNY Buffalo wrote the language-switching code, the Modula-2 
  194. support, and contributed the Languages chapter of this manual. 
  195.  
  196. Fred Fish wrote most of the support for Unix System Vr4. He also enhanced the 
  197. command-completion support to cover C++ overloaded symbols. 
  198.  
  199. Hitachi America, Ltd. sponsored the support for Hitachi microprocessors. 
  200.  
  201. Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware watchpoints. 
  202.  
  203. Stu Grossman wrote gdbserver. 
  204.  
  205. Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman made nearly 
  206. innumerable bug fixes and cleanups throughout GDB. 
  207.  
  208.  
  209. ΓòÉΓòÉΓòÉ 4. A Sample GDB Session ΓòÉΓòÉΓòÉ
  210.  
  211. You can use this manual at your leisure to read all about GDB. However, a 
  212. handful of commands are enough to get started using the debugger.  This chapter 
  213. illustrates those commands. 
  214.  
  215. One of the preliminary versions of gnu m4 (a generic macro processor) exhibits 
  216. the following bug: sometimes, when we change its quote strings from the 
  217. default, the commands used to capture one macro definition within another stop 
  218. working.  In the following short m4 session, we define a macro foo which 
  219. expands to 0000; we then use the m4 built-in defn to define bar as the same 
  220. thing.  However, when we change the open quote string to <QUOTE> and the close 
  221. quote string to <UNQUOTE>, the same procedure fails to define a new synonym 
  222. baz: 
  223.  
  224. $ cd gnu/m4
  225. $ ./m4
  226. define(foo,0000)
  227.  
  228. foo
  229. 0000
  230. define(bar,defn(`foo'))
  231.  
  232. bar
  233. 0000
  234. changequote(<QUOTE>,<UNQUOTE>)
  235.  
  236. define(baz,defn(<QUOTE>foo<UNQUOTE>))
  237. baz
  238. C-d
  239. m4: End of input: 0: fatal error: EOF in string
  240.  
  241. Let us use GDB to try to see what is going on. 
  242.  
  243. $ gdb m4
  244. GDB is free software and you are welcome to distribute copies
  245.  of it under certain conditions; type "show copying" to see
  246.  the conditions.
  247. There is absolutely no warranty for GDB; type "show warranty"
  248.  for details.
  249.  
  250. GDB 4.16, Copyright 1995 Free Software Foundation, Inc...
  251. (gdb)
  252.  
  253. GDB reads only enough symbol data to know where to find the rest when needed; 
  254. as a result, the first prompt comes up very quickly. We now tell GDB to use a 
  255. narrower display width than usual, so that examples fit in this manual. 
  256.  
  257. (gdb) set width 70
  258.  
  259. We need to see how the m4 built-in changequote works. Having looked at the 
  260. source, we know the relevant subroutine is m4_changequote, so we set a 
  261. breakpoint there with the GDB break command. 
  262.  
  263. (gdb) break m4_changequote
  264. Breakpoint 1 at 0x62f4: file builtin.c, line 879.
  265.  
  266. Using the run command, we start m4 running under GDB control; as long as 
  267. control does not reach the m4_changequote subroutine, the program runs as 
  268. usual: 
  269.  
  270. (gdb) run
  271. Starting program: /work/Editorial/gdb/gnu/m4/m4
  272. define(foo,0000)
  273.  
  274. foo
  275. 0000
  276.  
  277. To trigger the breakpoint, we call changequote.  GDB suspends execution of m4, 
  278. displaying information about the context where it stops. 
  279.  
  280. changequote(<QUOTE>,<UNQUOTE>)
  281.  
  282. Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)
  283.     at builtin.c:879
  284. 879         if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))
  285.  
  286. Now we use the command n (next) to advance execution to the next line of the 
  287. current function. 
  288.  
  289. (gdb) n
  290. 882         set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
  291.  : nil,
  292.  
  293. set_quotes looks like a promising subroutine.  We can go into it by using the 
  294. command s (step) instead of next. step goes to the next line to be executed in 
  295. any subroutine, so it steps into set_quotes. 
  296.  
  297. (gdb) s
  298. set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  299.     at input.c:530
  300. 530         if (lquote != def_lquote)
  301.  
  302. The display that shows the subroutine where m4 is now suspended (and its 
  303. arguments) is called a stack frame display.  It shows a summary of the stack. 
  304. We can use the backtrace command (which can also be spelled bt), to see where 
  305. we are in the stack as a whole: the backtrace command displays a stack frame 
  306. for each active subroutine. 
  307.  
  308. (gdb) bt
  309. #0  set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  310.     at input.c:530
  311. #1  0x6344 in m4_changequote (argc=3, argv=0x33c70)
  312.     at builtin.c:882
  313. #2  0x8174 in expand_macro (sym=0x33320) at macro.c:242
  314. #3  0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
  315.     at macro.c:71
  316. #4  0x79dc in expand_input () at macro.c:40
  317. #5  0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
  318.  
  319. We step through a few more lines to see what happens.  The first two times, we 
  320. can use `s'; the next two times we use n to avoid falling into the xstrdup 
  321. subroutine. 
  322.  
  323. (gdb) s
  324. 0x3b5c  532         if (rquote != def_rquote)
  325. (gdb) s
  326. 0x3b80  535         lquote = (lq == nil || *lq == '\0') ?  \
  327. def_lquote : xstrdup(lq);
  328. (gdb) n
  329. 536         rquote = (rq == nil || *rq == '\0') ? def_rquote\
  330.  : xstrdup(rq);
  331. (gdb) n
  332. 538         len_lquote = strlen(rquote);
  333.  
  334. The last line displayed looks a little odd; we can examine the variables lquote 
  335. and rquote to see if they are in fact the new left and right quotes we 
  336. specified.  We use the command p (print) to see their values. 
  337.  
  338. (gdb) p lquote
  339. $1 = 0x35d40 "<QUOTE>"
  340. (gdb) p rquote
  341. $2 = 0x35d50 "<UNQUOTE>"
  342.  
  343. lquote and rquote are indeed the new left and right quotes. To look at some 
  344. context, we can display ten lines of source surrounding the current line with 
  345. the l (list) command. 
  346.  
  347. (gdb) l
  348. 533             xfree(rquote);
  349. 534
  350. 535         lquote = (lq == nil || *lq == '\0') ? def_lquote\
  351.  : xstrdup (lq);
  352. 536         rquote = (rq == nil || *rq == '\0') ? def_rquote\
  353.  : xstrdup (rq);
  354. 537
  355. 538         len_lquote = strlen(rquote);
  356. 539         len_rquote = strlen(lquote);
  357. 540     }
  358. 541
  359. 542     void
  360.  
  361. Let us step past the two lines that set len_lquote and len_rquote, and then 
  362. examine the values of those variables. 
  363.  
  364. (gdb) n
  365. 539         len_rquote = strlen(lquote);
  366. (gdb) n
  367. 540     }
  368. (gdb) p len_lquote
  369. $3 = 9
  370. (gdb) p len_rquote
  371. $4 = 7
  372.  
  373. That certainly looks wrong, assuming len_lquote and len_rquote are meant to be 
  374. the lengths of lquote and rquote respectively.  We can set them to better 
  375. values using the p command, since it can print the value of any 
  376. expression---and that expression can include subroutine calls and assignments. 
  377.  
  378. (gdb) p len_lquote=strlen(lquote)
  379. $5 = 7
  380. (gdb) p len_rquote=strlen(rquote)
  381. $6 = 9
  382.  
  383. Is that enough to fix the problem of using the new quotes with the m4 built-in 
  384. defn?  We can allow m4 to continue executing with the c (continue) command, and 
  385. then try the example that caused trouble initially: 
  386.  
  387. (gdb) c
  388. Continuing.
  389.  
  390. define(baz,defn(<QUOTE>foo<UNQUOTE>))
  391.  
  392. baz
  393. 0000
  394.  
  395. Success!  The new quotes now work just as well as the default ones.  The 
  396. problem seems to have been just the two typos defining the wrong lengths.  We 
  397. allow m4 exit by giving it an EOF as input: 
  398.  
  399. C-d
  400. Program exited normally.
  401.  
  402. The message `Program exited normally.' is from GDB; it indicates m4 has 
  403. finished executing.  We can end our GDB session with the GDB quit command. 
  404.  
  405. (gdb) quit
  406.  
  407.  
  408. ΓòÉΓòÉΓòÉ 5. Getting In and Out of GDB ΓòÉΓòÉΓòÉ
  409.  
  410. This chapter discusses how to start GDB, and how to get out of it. The 
  411. essentials are: 
  412.  
  413.      type `gdb' to start GDB. 
  414.  
  415.      type quit or C-d to exit. 
  416.  
  417.  Invoking GDB                            How to start GDBN 
  418.  Quitting GDB                            How to quit GDBN 
  419.  Shell Commands                          How to use shell commands inside GDBN 
  420.  
  421.  
  422. ΓòÉΓòÉΓòÉ 5.1. Invoking GDB ΓòÉΓòÉΓòÉ
  423.  
  424. Invoke GDB by running the program gdb.  Once started, GDB reads commands from 
  425. the terminal until you tell it to exit. 
  426.  
  427. You can also run gdb with a variety of arguments and options, to specify more 
  428. of your debugging environment at the outset. 
  429.  
  430. The command-line options described here are designed to cover a variety of 
  431. situations; in some environments, some of these options may effectively be 
  432. unavailable. 
  433.  
  434. The most usual way to start GDB is with one argument, specifying an executable 
  435. program: 
  436.  
  437. gdb program
  438.  
  439. You can also start with both an executable program and a core file specified: 
  440.  
  441. gdb program core
  442.  
  443. You can, instead, specify a process ID as a second argument, if you want to 
  444. debug a running process: 
  445.  
  446. gdb program 1234
  447.  
  448. would attach GDB to process 1234 (unless you also have a file named `1234'; GDB 
  449. does check for a core file first). 
  450.  
  451. Taking advantage of the second command-line argument requires a fairly complete 
  452. operating system; when you use GDB as a remote debugger attached to a bare 
  453. board, there may not be any notion of ``process'', and there is often no way to 
  454. get a core dump. 
  455.  
  456. You can run gdb without printing the front material, which describes GDB's 
  457. non-warranty, by specifying -silent: 
  458.  
  459. gdb -silent
  460.  
  461. You can further control how GDB starts up by using command-line options.  GDB 
  462. itself can remind you of the options available. 
  463.  
  464. Type 
  465.  
  466. gdb -help
  467.  
  468. to display all available options and briefly describe their use (`gdb -h' is a 
  469. shorter equivalent). 
  470.  
  471. All options and command line arguments you give are processed in sequential 
  472. order.  The order makes a difference when the `-x' option is used. 
  473.  
  474.  Remote Serial                           GDBN remote serial protocol 
  475.  
  476.  i960-Nindy Remote                       GDBN with a remote i960 (Nindy) 
  477.  
  478.  UDI29K Remote                           The UDI protocol for AMD29K 
  479.  EB29K Remote                            The EBMON protocol for AMD29K 
  480.  
  481.  VxWorks Remote                          GDBN and VxWorks 
  482.  
  483.  ST2000 Remote                           GDBN with a Tandem ST2000 
  484.  
  485.  Hitachi Remote                          GDBN and Hitachi Microprocessors 
  486.  
  487.  MIPS Remote                             GDBN and MIPS boards 
  488.  
  489.  Simulator                               Simulated CPU target 
  490.  
  491.  File Options                            Choosing files 
  492.  Mode Options                            Choosing modes 
  493.  
  494.  
  495. ΓòÉΓòÉΓòÉ 5.1.1. Choosing files ΓòÉΓòÉΓòÉ
  496.  
  497. When GDB starts, it reads any arguments other than options as specifying an 
  498. executable file and core file (or process ID).  This is the same as if the 
  499. arguments were specified by the `-se' and `-c' options respectively.  (GDB 
  500. reads the first argument that does not have an associated option flag as 
  501. equivalent to the `-se' option followed by that argument; and the second 
  502. argument that does not have an associated option flag, if any, as equivalent to 
  503. the `-c' option followed by that argument.) 
  504.  
  505. Many options have both long and short forms; both are shown in the following 
  506. list.  GDB also recognizes the long forms if you truncate them, so long as 
  507. enough of the option is present to be unambiguous. (If you prefer, you can flag 
  508. option arguments with `--' rather than `-', though we illustrate the more usual 
  509. convention.) 
  510.  
  511.  -symbols file 
  512.  -s file 
  513.            Read symbol table from file file. 
  514.  
  515.  -exec file 
  516.  -e file 
  517.            Use file file as the executable file to execute when appropriate, 
  518.            and for examining pure data in conjunction with a core dump. 
  519.  
  520.  -se file 
  521.            Read symbol table from file file and use it as the executable file. 
  522.  
  523.  -core file 
  524.  -c file 
  525.            Use file file as a core dump to examine. 
  526.  
  527.  -c number 
  528.            Connect to process ID number, as with the attach command (unless 
  529.            there is a file in core-dump format named number, in which case `-c' 
  530.            specifies that file as a core dump to read). 
  531.  
  532.  -command file 
  533.  -x file 
  534.            Execute GDB commands from file file. See Command files. 
  535.  
  536.  -directory directory 
  537.  -d directory 
  538.            Add directory to the path to search for source files. 
  539.  
  540.  -m 
  541.  -mapped 
  542.            Warning: this option depends on operating system facilities that are 
  543.            not supported on all systems. 
  544.            If memory-mapped files are available on your system through the mmap 
  545.            system call, you can use this option to have GDB write the symbols 
  546.            from your program into a reusable file in the current directory.  If 
  547.            the program you are debugging is called `/tmp/fred', the mapped 
  548.            symbol file is `./fred.syms'. Future GDB debugging sessions notice 
  549.            the presence of this file, and can quickly map in symbol information 
  550.            from it, rather than reading the symbol table from the executable 
  551.            program. 
  552.  
  553.            The `.syms' file is specific to the host machine where GDB is run. 
  554.            It holds an exact image of the internal GDB symbol table.  It cannot 
  555.            be shared across multiple host platforms. 
  556.  
  557.  -r 
  558.  -readnow 
  559.            Read each symbol file's entire symbol table immediately, rather than 
  560.            the default, which is to read it incrementally as it is needed. This 
  561.            makes startup slower, but makes future operations faster. 
  562.  
  563.  The -mapped and -readnow options are typically combined in order to build a 
  564.  `.syms' file that contains complete symbol information.  (See Commands to 
  565.  specify files, for information 
  566.  
  567.  a `.syms' file for future use is: 
  568.  
  569.           gdb -batch -nx -mapped -readnow programname
  570.  
  571.  
  572. ΓòÉΓòÉΓòÉ 5.1.2. Choosing modes ΓòÉΓòÉΓòÉ
  573.  
  574. You can run GDB in various alternative modes---for example, in batch mode or 
  575. quiet mode. 
  576.  
  577.  -nx 
  578.  -n 
  579.            Do not execute commands from any initialization files (normally 
  580.            called `.gdbinit').  Normally, the commands in these files are 
  581.            executed after all the command options and arguments have been 
  582.            processed.  See Command files. 
  583.  
  584.  -quiet 
  585.  -q 
  586.            ``Quiet''.  Do not print the introductory and copyright messages. 
  587.            These messages are also suppressed in batch mode. 
  588.  
  589.  -batch 
  590.            Run in batch mode.  Exit with status 0 after processing all the 
  591.            command files specified with `-x' (and all commands from 
  592.            initialization files, if not inhibited with `-n').  Exit with 
  593.            nonzero status if an error occurs in executing the GDB commands in 
  594.            the command files. 
  595.  
  596.            Batch mode may be useful for running GDB as a filter, for example to 
  597.            download and run a program on another computer; in order to make 
  598.            this more useful, the message 
  599.  
  600.                       Program exited normally.
  601.  
  602.            (which is ordinarily issued whenever a program running under GDB 
  603.            control terminates) is not issued when running in batch mode. 
  604.  
  605.  -cd directory 
  606.            Run GDB using directory as its working directory, instead of the 
  607.            current directory. 
  608.  
  609.  -fullname 
  610.  -f 
  611.            gnu Emacs sets this option when it runs GDB as a subprocess.  It 
  612.            tells GDB to output the full file name and line number in a 
  613.            standard, recognizable fashion each time a stack frame is displayed 
  614.            (which includes each time your program stops).  This recognizable 
  615.            format looks like two `\032' characters, followed by the file name, 
  616.            line number and character position separated by colons, and a 
  617.            newline.  The Emacs-to-GDB interface program uses the two `\032' 
  618.            characters as a signal to display the source code for the frame. 
  619.  
  620.  -b bps 
  621.            Set the line speed (baud rate or bits per second) of any serial 
  622.            interface used by GDB for remote debugging. 
  623.  
  624.  -tty device 
  625.            Run using device for your program's standard input and output. 
  626.  
  627.  
  628. ΓòÉΓòÉΓòÉ 5.2. Quitting GDB ΓòÉΓòÉΓòÉ
  629.  
  630.  quit 
  631.            To exit GDB, use the quit command (abbreviated q), or type an 
  632.            end-of-file character (usually C-d).  If you do not supply 
  633.            expression, GDB will terminate normally; otherwise it will terminate 
  634.            using the result of expression as the error code. 
  635.  
  636.  An interrupt (often C-c) does not exit from GDB, but rather terminates the 
  637.  action of any GDB command that is in progress and returns to GDB command 
  638.  level.  It is safe to type the interrupt character at any time because GDB 
  639.  does not allow it to take effect until a time when it is safe. 
  640.  
  641.  If you have been using GDB to control an attached process or device, you can 
  642.  release it with the detach command (see Debugging an already-running process). 
  643.  
  644.  
  645. ΓòÉΓòÉΓòÉ 5.3. Shell commands ΓòÉΓòÉΓòÉ
  646.  
  647. If you need to execute occasional shell commands during your debugging session, 
  648. there is no need to leave or suspend GDB; you can just use the shell command. 
  649.  
  650.  shell command string 
  651.            Invoke a the standard shell to execute command string. If it exists, 
  652.            the environment variable SHELL determines which shell to run. 
  653.            Otherwise GDB uses /bin/sh. 
  654.  
  655.  The utility make is often needed in development environments. You do not have 
  656.  to use the shell command for this purpose in GDB: 
  657.  
  658.  make make-args 
  659.            Execute the make program with the specified arguments.  This is 
  660.            equivalent to `shell make make-args'. 
  661.  
  662.  
  663. ΓòÉΓòÉΓòÉ 6. GDB Commands ΓòÉΓòÉΓòÉ
  664.  
  665. You can abbreviate a GDB command to the first few letters of the command name, 
  666. if that abbreviation is unambiguous; and you can repeat certain GDB commands by 
  667. typing just RET.  You can also use the TAB key to get GDB to fill out the rest 
  668. of a word in a command (or to show you the alternatives available, if there is 
  669. more than one possibility). 
  670.  
  671.  Command Syntax                          How to give commands to GDBN 
  672.  Completion                              Command completion 
  673.  Help                                    How to ask GDBN for help 
  674.  
  675.  
  676. ΓòÉΓòÉΓòÉ 6.1. Command syntax ΓòÉΓòÉΓòÉ
  677.  
  678. A GDB command is a single line of input.  There is no limit on how long it can 
  679. be.  It starts with a command name, which is followed by arguments whose 
  680. meaning depends on the command name.  For example, the command step accepts an 
  681. argument which is the number of times to step, as in `step 5'.  You can also 
  682. use the step command with no arguments.  Some command names do not allow any 
  683. arguments. 
  684.  
  685. GDB command names may always be truncated if that abbreviation is unambiguous. 
  686. Other possible command abbreviations are listed in the documentation for 
  687. individual commands.  In some cases, even ambiguous abbreviations are allowed; 
  688. for example, s is specially defined as equivalent to step even though there are 
  689. other commands whose names start with s.  You can test abbreviations by using 
  690. them as arguments to the help command. 
  691.  
  692. A blank line as input to GDB (typing just RET) means to repeat the previous 
  693. command. Certain commands (for example, run) will not repeat this way; these 
  694. are commands whose unintentional repetition might cause trouble and which you 
  695. are unlikely to want to repeat. 
  696.  
  697. The list and x commands, when you repeat them with RET, construct new arguments 
  698. rather than repeating exactly as typed.  This permits easy scanning of source 
  699. or memory. 
  700.  
  701. GDB can also use RET in another way: to partition lengthy output, in a way 
  702. similar to the common utility more (see Screen size).  Since it is easy to 
  703. press one RET too many in this situation, GDB disables command repetition after 
  704. any command that generates this sort of display. 
  705.  
  706. Any text from a # to the end of the line is a comment; it does nothing.  This 
  707. is useful mainly in command files ( see Command files). 
  708.  
  709.  
  710. ΓòÉΓòÉΓòÉ 6.2. Command completion ΓòÉΓòÉΓòÉ
  711.  
  712. GDB can fill in the rest of a word in a command for you, if there is only one 
  713. possibility; it can also show you what the valid possibilities are for the next 
  714. word in a command, at any time.  This works for GDB commands, GDB subcommands, 
  715. and the names of symbols in your program. 
  716.  
  717. Press the TAB key whenever you want GDB to fill out the rest of a word.  If 
  718. there is only one possibility, GDB fills in the word, and waits for you to 
  719. finish the command (or press RET to enter it).  For example, if you type 
  720.  
  721. (gdb) info bre TAB
  722.  
  723. GDB fills in the rest of the word `breakpoints', since that is the only info 
  724. subcommand beginning with `bre': 
  725.  
  726. (gdb) info breakpoints
  727.  
  728. You can either press RET at this point, to run the info breakpoints command, or 
  729. backspace and enter something else, if `breakpoints' does not look like the 
  730. command you expected.  (If you were sure you wanted info breakpoints in the 
  731. first place, you might as well just type RET immediately after `info bre', to 
  732. exploit command abbreviations rather than command completion). 
  733.  
  734. If there is more than one possibility for the next word when you press TAB, GDB 
  735. sounds a bell.  You can either supply more characters and try again, or just 
  736. press TAB a second time; GDB displays all the possible completions for that 
  737. word.  For example, you might want to set a breakpoint on a subroutine whose 
  738. name begins with `make_', but when you type b make_TAB GDB just sounds the 
  739. bell.  Typing TAB again displays all the function names in your program that 
  740. begin with those characters, for example: 
  741.  
  742. (gdb) b make_ TAB
  743. GDB sounds bell; press TAB again, to see:
  744. make_a_section_from_file     make_environ
  745. make_abs_section             make_function_type
  746. make_blockvector             make_pointer_type
  747. make_cleanup                 make_reference_type
  748. make_command                 make_symbol_completion_list
  749. (gdb) b make_
  750.  
  751. After displaying the available possibilities, GDB copies your partial input (`b 
  752. make_' in the example) so you can finish the command. 
  753.  
  754. If you just want to see the list of alternatives in the first place, you can 
  755. press M-? rather than pressing TAB twice. M-? means META ?.  You can type this 
  756. either by holding down a key designated as the META shift on your keyboard (if 
  757. there is one) while typing ?, or as ESC followed by ?. 
  758.  
  759. Sometimes the string you need, while logically a ``word'', may contain 
  760. parentheses or other characters that GDB normally excludes from its notion of a 
  761. word.  To permit word completion to work in this situation, you may enclose 
  762. words in ' (single quote marks) in GDB commands. 
  763.  
  764. The most likely situation where you might need this is in typing the name of a 
  765. C++ function.  This is because C++ allows function overloading (multiple 
  766. definitions of the same function, distinguished by argument type).  For 
  767. example, when you want to set a breakpoint you may need to distinguish whether 
  768. you mean the version of name that takes an int parameter, name(int), or the 
  769. version that takes a float parameter, name(float).  To use the word-completion 
  770. facilities in this situation, type a single quote ' at the beginning of the 
  771. function name.  This alerts GDB that it may need to consider more information 
  772. than usual when you press TAB or M-? to request word completion: 
  773.  
  774. (gdb) b 'bubble( M-?
  775. bubble(double,double)    bubble(int,int)
  776. (gdb) b 'bubble(
  777.  
  778. In some cases, GDB can tell that completing a name requires using quotes.  When 
  779. this happens, GDB inserts the quote for you (while completing as much as it 
  780. can) if you do not type the quote in the first place: 
  781.  
  782. (gdb) b bub TAB
  783. GDB alters your input line to the following, and rings a bell:
  784. (gdb) b 'bubble(
  785.  
  786. In general, GDB can tell that a quote is needed (and inserts it) if you have 
  787. not yet started typing the argument list when you ask for completion on an 
  788. overloaded symbol. 
  789.  
  790.  
  791. ΓòÉΓòÉΓòÉ 6.3. Getting help ΓòÉΓòÉΓòÉ
  792.  
  793. You can always ask GDB itself for information on its commands, using the 
  794. command help. 
  795.  
  796.  help 
  797.  h 
  798.            You can use help (abbreviated h) with no arguments to display a 
  799.            short list of named classes of commands: 
  800.  
  801.                       (gdb) help
  802.                       List of classes of commands:
  803.  
  804.                       running -- Running the program
  805.                       stack -- Examining the stack
  806.                       data -- Examining data
  807.                       breakpoints -- Making program stop at certain points
  808.                       files -- Specifying and examining files
  809.                       status -- Status inquiries
  810.                       support -- Support facilities
  811.                       user-defined -- User-defined commands
  812.                       aliases -- Aliases of other commands
  813.                       obscure -- Obscure features
  814.  
  815.                       Type "help" followed by a class name for a list of
  816.                       commands in that class.
  817.                       Type "help" followed by command name for full
  818.                       documentation.
  819.                       Command name abbreviations are allowed if unambiguous.
  820.                       (gdb)
  821.  
  822.  help class 
  823.            Using one of the general help classes as an argument, you can get a 
  824.            list of the individual commands in that class.  For example, here is 
  825.            the help display for the class status: 
  826.  
  827.                       (gdb) help status
  828.                       Status inquiries.
  829.  
  830.                       List of commands:
  831.  
  832.                       show -- Generic command for showing things set
  833.                        with "set"
  834.                       info -- Generic command for printing status
  835.  
  836.                       Type "help" followed by command name for full
  837.                       documentation.
  838.                       Command name abbreviations are allowed if unambiguous.
  839.                       (gdb)
  840.  
  841.  help command 
  842.            With a command name as help argument, GDB displays a short paragraph 
  843.            on how to use that command. 
  844.  
  845.  complete args 
  846.            The complete args command lists all the possible completions for the 
  847.            beginning of a command.  Use args to specify the beginning of the 
  848.            command you want completed.  For example: 
  849.  
  850.                       complete i
  851.  
  852.            results in: 
  853.  
  854.                       info
  855.                       inspect
  856.                       ignore
  857.  
  858.            This is intended for use by gnu Emacs. 
  859.  
  860.  In addition to help, you can use the GDB commands info and show to inquire 
  861.  about the state of your program, or the state of GDB itself.  Each command 
  862.  supports many topics of inquiry; this manual introduces each of them in the 
  863.  appropriate context.  The listings under info and under show in the Index 
  864.  point to all the sub-commands.  See Index. 
  865.  
  866.  info 
  867.            This command (abbreviated i) is for describing the state of your 
  868.            program.  For example, you can list the arguments given to your 
  869.            program with info args, list the registers currently in use with 
  870.            info registers, or list the breakpoints you have set with info 
  871.            breakpoints. You can get a complete list of the info sub-commands 
  872.            with help info. 
  873.  
  874.  set 
  875.            You can assign the result of an expresson to an environment variable 
  876.            with set.  For example, you can set the GDB prompt to a $-sign with 
  877.            set prompt $. 
  878.  
  879.  show 
  880.            In contrast to info, show is for describing the state of GDB itself. 
  881.            You can change most of the things you can show, by using the related 
  882.            command set; for example, you can control what number system is used 
  883.            for displays with set radix, or simply inquire which is currently in 
  884.            use with show radix. 
  885.  
  886.            To display all the settable parameters and their current values, you 
  887.            can use show with no arguments; you may also use info set.  Both 
  888.            commands produce the same display. 
  889.  
  890.  Here are three miscellaneous show subcommands, all of which are exceptional in 
  891.  lacking corresponding set commands: 
  892.  
  893.  show version 
  894.            Show what version of GDB is running.  You should include this 
  895.            information in GDB bug-reports.  If multiple versions of GDB are in 
  896.            use at your site, you may occasionally want to determine which 
  897.            version of GDB you are running; as GDB evolves, new commands are 
  898.            introduced, and old ones may wither away.  The version number is 
  899.            also announced when you start GDB. 
  900.  
  901.  show copying 
  902.            Display information about permission for copying GDB. 
  903.  
  904.  show warranty 
  905.            Display the gnu ``NO WARRANTY'' statement. 
  906.  
  907.  
  908. ΓòÉΓòÉΓòÉ 7. Running Programs Under GDB ΓòÉΓòÉΓòÉ
  909.  
  910. When you run a program under GDB, you must first generate debugging information 
  911. when you compile it. You may start GDB with its arguments, if any, in an 
  912. environment of your choice.  You may redirect your program's input and output, 
  913. debug an already running process, or kill a child process. 
  914.  
  915.  Compilation                             Compiling for debugging 
  916.  Starting                                Starting your program 
  917.  
  918.  Arguments                               Your program's arguments 
  919.  Environment                             Your program's environment 
  920.  Working Directory                       Your program's working directory 
  921.  Input/Output                            Your program's input and output 
  922.  Attach                                  Debugging an already-running process 
  923.  Kill Process                            Killing the child process 
  924.  Process Information                     Additional process information 
  925.  Threads                                 Debugging programs with multiple 
  926.                                          threads 
  927.  Processes                               Debugging programs with multiple 
  928.                                          processes 
  929.  
  930.  
  931. ΓòÉΓòÉΓòÉ 7.1. Compiling for debugging ΓòÉΓòÉΓòÉ
  932.  
  933. In order to debug a program effectively, you need to generate debugging 
  934. information when you compile it.  This debugging information is stored in the 
  935. object file; it describes the data type of each variable or function and the 
  936. correspondence between source line numbers and addresses in the executable 
  937. code. 
  938.  
  939. To request debugging information, specify the `-g' option when you run the 
  940. compiler. 
  941.  
  942. Many C compilers are unable to handle the `-g' and `-O' options together. 
  943. Using those compilers, you cannot generate optimized executables containing 
  944. debugging information. 
  945.  
  946. GCC, the gnu C compiler, supports `-g' with or without `-O', making it possible 
  947. to debug optimized code.  We recommend that you always use `-g' whenever you 
  948. compile a program. You may think your program is correct, but there is no sense 
  949. in pushing your luck. 
  950.  
  951. When you debug a program compiled with `-g -O', remember that the optimizer is 
  952. rearranging your code; the debugger shows you what is really there.  Do not be 
  953. too surprised when the execution path does not exactly match your source file! 
  954. An extreme example: if you define a variable, but never use it, GDB never sees 
  955. that variable---because the compiler optimizes it out of existence. 
  956.  
  957. Some things do not work as well with `-g -O' as with just `-g', particularly on 
  958. machines with instruction scheduling.  If in doubt, recompile with `-g' alone, 
  959. and if this fixes the problem, please report it to us as a bug (including a 
  960. test case!). 
  961.  
  962. Older versions of the gnu C compiler permitted a variant option `-gg' for 
  963. debugging information.  GDB no longer supports this format; if your gnu C 
  964. compiler has this option, do not use it. 
  965.  
  966.  
  967. ΓòÉΓòÉΓòÉ 7.2. Starting your program ΓòÉΓòÉΓòÉ
  968.  
  969.  run 
  970.  r 
  971.            Use the run command to start your program under GDB.  You must first 
  972.            specify the program name (except on VxWorks) with an argument to GDB 
  973.            ( see Getting In and Out of GDB), or by using the file or exec-file 
  974.            command (see Commands to specify files). 
  975.  
  976.  If you are running your program in an execution environment that supports 
  977.  processes, run creates an inferior process and makes that process run your 
  978.  program.  (In environments without processes, run jumps to the start of your 
  979.  program.) 
  980.  
  981.  The execution of a program is affected by certain information it receives from 
  982.  its superior.  GDB provides ways to specify this information, which you must 
  983.  do before starting your program.  (You can change it after starting your 
  984.  program, but such changes only affect your program the next time you start 
  985.  it.)  This information may be divided into four categories: 
  986.  
  987.  The arguments. 
  988.            Specify the arguments to give your program as the arguments of the 
  989.            run command.  If a shell is available on your target, the shell is 
  990.            used to pass the arguments, so that you may use normal conventions 
  991.            (such as wildcard expansion or variable substitution) in describing 
  992.            the arguments.  In Unix systems, you can control which shell is used 
  993.            with the SHELL environment variable. See Your program_s arguments. 
  994.  
  995.  The environment. 
  996.            Your program normally inherits its environment from GDB, but you can 
  997.            use the GDB commands set environment and unset environment to change 
  998.            parts of the environment that affect your program.  See Your 
  999.            program_s environment. 
  1000.  
  1001.  The working directory. 
  1002.            Your program inherits its working directory from GDB.  You can set 
  1003.            the GDB working directory with the cd command in GDB. See Your 
  1004.            program_s working directory. 
  1005.  
  1006.  The standard input and output. 
  1007.            Your program normally uses the same device for standard input and 
  1008.            standard output as GDB is using.  You can redirect input and output 
  1009.            in the run command line, or you can use the tty command to set a 
  1010.            different device for your program. See Your program_s input and 
  1011.            output. 
  1012.  
  1013.            Warning: While input and output redirection work, you cannot use 
  1014.            pipes to pass the output of the program you are debugging to another 
  1015.            program; if you attempt this, GDB is likely to wind up debugging the 
  1016.            wrong program. 
  1017.  
  1018.  When you issue the run command, your program begins to execute immediately. 
  1019.  See Stopping and continuing, for discussion of how to arrange for your program 
  1020.  to stop.  Once your program has stopped, you may call functions in your 
  1021.  program, using the print or call commands.  See Examining Data. 
  1022.  
  1023.  If the modification time of your symbol file has changed since the last time 
  1024.  GDB read its symbols, GDB discards its symbol table, and reads it again.  When 
  1025.  it does this, GDB tries to retain your current breakpoints. 
  1026.  
  1027.  
  1028. ΓòÉΓòÉΓòÉ 7.3. Your program's arguments ΓòÉΓòÉΓòÉ
  1029.  
  1030. The arguments to your program can be specified by the arguments of the run 
  1031. command.  They are passed to a shell, which expands wildcard characters and 
  1032. performs redirection of I/O, and thence to your program. Your SHELL environment 
  1033. variable (if it exists) specifies what shell GDB uses.  If you do not define 
  1034. SHELL, GDB uses /bin/sh. 
  1035.  
  1036. run with no arguments uses the same arguments used by the previous run, or 
  1037. those set by the set args command. 
  1038.  
  1039.  set args 
  1040.            Specify the arguments to be used the next time your program is run. 
  1041.            If set args has no arguments, run executes your program with no 
  1042.            arguments.  Once you have run your program with arguments, using set 
  1043.            args before the next run is the only way to run it again without 
  1044.            arguments. 
  1045.  
  1046.  show args 
  1047.            Show the arguments to give your program when it is started. 
  1048.  
  1049.  
  1050. ΓòÉΓòÉΓòÉ 7.4. Your program's environment ΓòÉΓòÉΓòÉ
  1051.  
  1052. The environment consists of a set of environment variables and their values. 
  1053. Environment variables conventionally record such things as your user name, your 
  1054. home directory, your terminal type, and your search path for programs to run. 
  1055. Usually you set up environment variables with the shell and they are inherited 
  1056. by all the other programs you run.  When debugging, it can be useful to try 
  1057. running your program with a modified environment without having to start GDB 
  1058. over again. 
  1059.  
  1060.  path directory 
  1061.            Add directory to the front of the PATH environment variable (the 
  1062.            search path for executables), for both GDB and your program. You may 
  1063.            specify several directory names, separated by `:' or whitespace.  If 
  1064.            directory is already in the path, it is moved to the front, so it is 
  1065.            searched sooner. 
  1066.  
  1067.            You can use the string `$cwd' to refer to whatever is the current 
  1068.            working directory at the time GDB searches the path.  If you use `.' 
  1069.            instead, it refers to the directory where you executed the path 
  1070.            command.  GDB replaces `.' in the directory argument (with the 
  1071.            current path) before adding directory to the search path. 
  1072.  
  1073.  show paths 
  1074.            Display the list of search paths for executables (the PATH 
  1075.            environment variable). 
  1076.  
  1077.  show environment [varname] 
  1078.            Print the value of environment variable varname to be given to your 
  1079.            program when it starts.  If you do not supply varname, print the 
  1080.            names and values of all environment variables to be given to your 
  1081.            program.  You can abbreviate environment as env. 
  1082.  
  1083.  set environment varname [=] value 
  1084.            Set environment variable varname to value.  The value changes for 
  1085.            your program only, not for GDB itself.  value may be any string; the 
  1086.            values of environment variables are just strings, and any 
  1087.            interpretation is supplied by your program itself.  The value 
  1088.            parameter is optional; if it is eliminated, the variable is set to a 
  1089.            null value. 
  1090.  
  1091.            For example, this command: 
  1092.  
  1093.                       set env USER = foo
  1094.  
  1095.            tells a Unix program, when subsequently run, that its user is named 
  1096.            `foo'.  (The spaces around `=' are used for clarity here; they are 
  1097.            not actually required.) 
  1098.  
  1099.  unset environment varname 
  1100.            Remove variable varname from the environment to be passed to your 
  1101.            program.  This is different from `set env varname ='; unset 
  1102.            environment removes the variable from the environment, rather than 
  1103.            assigning it an empty value. 
  1104.  
  1105.  Warning: GDB runs your program using the shell indicated by your SHELL 
  1106.  environment variable if it exists (or /bin/sh if not).  If your SHELL variable 
  1107.  names a shell that runs an initialization file---such as `.cshrc' for C-shell, 
  1108.  or `.bashrc' for BASH---any variables you set in that file affect your 
  1109.  program.  You may wish to move setting of environment variables to files that 
  1110.  are only run when you sign on, such as `.login' or `.profile'. 
  1111.  
  1112.  
  1113. ΓòÉΓòÉΓòÉ 7.5. Your program's working directory ΓòÉΓòÉΓòÉ
  1114.  
  1115. Each time you start your program with run, it inherits its working directory 
  1116. from the current working directory of GDB. The GDB working directory is 
  1117. initially whatever it inherited from its parent process (typically the shell), 
  1118. but you can specify a new working directory in GDB with the cd command. 
  1119.  
  1120. The GDB working directory also serves as a default for the commands that 
  1121. specify files for GDB to operate on. See Commands to specify files. 
  1122.  
  1123.  cd directory 
  1124.            Set the GDB working directory to directory. 
  1125.  
  1126.  pwd 
  1127.            Print the GDB working directory. 
  1128.  
  1129.  
  1130. ΓòÉΓòÉΓòÉ 7.6. Your program's input and output ΓòÉΓòÉΓòÉ
  1131.  
  1132. By default, the program you run under GDB does input and output to the same 
  1133. terminal that GDB uses.  GDB switches the terminal to its own terminal modes to 
  1134. interact with you, but it records the terminal modes your program was using and 
  1135. switches back to them when you continue running your program. 
  1136.  
  1137.  info terminal 
  1138.            Displays information recorded by GDB about the terminal modes your 
  1139.            program is using. 
  1140.  
  1141.  You can redirect your program's input and/or output using shell redirection 
  1142.  with the run command.  For example, 
  1143.  
  1144.   run > outfile
  1145.  
  1146.  starts your program, diverting its output to the file `outfile'. 
  1147.  
  1148.  Another way to specify where your program should do input and output is with 
  1149.  the tty command.  This command accepts a file name as argument, and causes 
  1150.  this file to be the default for future run commands.  It also resets the 
  1151.  controlling terminal for the child process, for future run commands.  For 
  1152.  example, 
  1153.  
  1154.   tty /dev/ttyb
  1155.  
  1156.  directs that processes started with subsequent run commands default to do 
  1157.  input and output on the terminal `/dev/ttyb' and have that as their 
  1158.  controlling terminal. 
  1159.  
  1160.  An explicit redirection in run overrides the tty command's effect on the 
  1161.  input/output device, but not its effect on the controlling terminal. 
  1162.  
  1163.  When you use the tty command or redirect input in the run command, only the 
  1164.  input for your program is affected.  The input for GDB still comes from your 
  1165.  terminal. 
  1166.  
  1167.  
  1168. ΓòÉΓòÉΓòÉ 7.7. Debugging an already-running process ΓòÉΓòÉΓòÉ
  1169.  
  1170.  attach process-id 
  1171.            This command attaches to a running process---one that was started 
  1172.            outside GDB.  (info files shows your active targets.)  The command 
  1173.            takes as argument a process ID.  The usual way to find out the 
  1174.            process-id of a Unix process is with the ps utility, or with the 
  1175.            `jobs -l' shell command. 
  1176.  
  1177.            attach does not repeat if you press RET a second time after 
  1178.            executing the command. 
  1179.  
  1180.  To use attach, your program must be running in an environment which supports 
  1181.  processes; for example, attach does not work for programs on bare-board 
  1182.  targets that lack an operating system.  You must also have permission to send 
  1183.  the process a signal. 
  1184.  
  1185.  When using attach, you should first use the file command to specify the 
  1186.  program running in the process and load its symbol table. See Commands to 
  1187.  Specify Files. 
  1188.  
  1189.  The first thing GDB does after arranging to debug the specified process is to 
  1190.  stop it.  You can examine and modify an attached process with all the GDB 
  1191.  commands that are ordinarily available when you start processes with run.  You 
  1192.  can insert breakpoints; you can step and continue; you can modify storage.  If 
  1193.  you would rather the process continue running, you may use the continue 
  1194.  command after attaching GDB to the process. 
  1195.  
  1196.  detach 
  1197.            When you have finished debugging the attached process, you can use 
  1198.            the detach command to release it from GDB control.  Detaching the 
  1199.            process continues its execution.  After the detach command, that 
  1200.            process and GDB become completely independent once more, and you are 
  1201.            ready to attach another process or start one with run. detach does 
  1202.            not repeat if you press RET again after executing the command. 
  1203.  
  1204.  If you exit GDB or use the run command while you have an attached process, you 
  1205.  kill that process.  By default, GDB asks for confirmation if you try to do 
  1206.  either of these things; you can control whether or not you need to confirm by 
  1207.  using the set confirm command ( see Optional warnings and messages). 
  1208.  
  1209.  
  1210. ΓòÉΓòÉΓòÉ 7.8. Killing the child process ΓòÉΓòÉΓòÉ
  1211.  
  1212.  kill 
  1213.            Kill the child process in which your program is running under GDB. 
  1214.  
  1215.  This command is useful if you wish to debug a core dump instead of a running 
  1216.  process.  GDB ignores any core dump file while your program is running. 
  1217.  
  1218.  On some operating systems, a program cannot be executed outside GDB while you 
  1219.  have breakpoints set on it inside GDB.  You can use the kill command in this 
  1220.  situation to permit running your program outside the debugger. 
  1221.  
  1222.  The kill command is also useful if you wish to recompile and relink your 
  1223.  program, since on many systems it is impossible to modify an executable file 
  1224.  while it is running in a process.  In this case, when you next type run, GDB 
  1225.  notices that the file has changed, and reads the symbol table again (while 
  1226.  trying to preserve your current breakpoint settings). 
  1227.  
  1228.  
  1229. ΓòÉΓòÉΓòÉ 7.9. Additional process information ΓòÉΓòÉΓòÉ
  1230.  
  1231. Some operating systems provide a facility called `/proc' that can be used to 
  1232. examine the image of a running process using file-system subroutines.  If GDB 
  1233. is configured for an operating system with this facility, the command info proc 
  1234. is available to report on several kinds of information about the process 
  1235. running your program. info proc works only on SVR4 systems that support procfs. 
  1236.  
  1237.  info proc 
  1238.            Summarize available information about the process. 
  1239.  
  1240.  info proc mappings 
  1241.            Report on the address ranges accessible in the program, with 
  1242.            information on whether your program may read, write, or execute each 
  1243.            range. 
  1244.  
  1245.  info proc times 
  1246.            Starting time, user CPU time, and system CPU time for your program 
  1247.            and its children. 
  1248.  
  1249.  info proc id 
  1250.            Report on the process IDs related to your program: its own process 
  1251.            ID, the ID of its parent, the process group ID, and the session ID. 
  1252.  
  1253.  info proc status 
  1254.            General information on the state of the process.  If the process is 
  1255.            stopped, this report includes the reason for stopping, and any 
  1256.            signal received. 
  1257.  
  1258.  info proc all 
  1259.            Show all the above information about the process. 
  1260.  
  1261.  
  1262. ΓòÉΓòÉΓòÉ 7.10. Debugging programs with multiple threads ΓòÉΓòÉΓòÉ
  1263.  
  1264. In some operating systems, a single program may have more than one thread of 
  1265. execution.  The precise semantics of threads differ from one operating system 
  1266. to another, but in general the threads of a single program are akin to multiple 
  1267. processes---except that they share one address space (that is, they can all 
  1268. examine and modify the same variables).  On the other hand, each thread has its 
  1269. own registers and execution stack, and perhaps private memory. 
  1270.  
  1271. GDB provides these facilities for debugging multi-thread programs: 
  1272.  
  1273.      automatic notification of new threads 
  1274.  
  1275.      `thread threadno', a command to switch among threads 
  1276.  
  1277.      `info threads', a command to inquire about existing threads 
  1278.  
  1279.      `thread apply [threadno] [all] args', a command to apply a command to a 
  1280.       list of threads 
  1281.  
  1282.      thread-specific breakpoints 
  1283.  
  1284.  Warning: These facilities are not yet available on every GDB configuration 
  1285.  where the operating system supports threads. If your GDB does not support 
  1286.  threads, these commands have no effect.  For example, a system without thread 
  1287.  support shows no output from `info threads', and always rejects the thread 
  1288.  command, like this: 
  1289.  
  1290.   (gdb) info threads
  1291.   (gdb) thread 1
  1292.   Thread ID 1 not known.  Use the "info threads" command to
  1293.   see the IDs of currently known threads.
  1294.  
  1295.  The GDB thread debugging facility allows you to observe all threads while your 
  1296.  program runs---but whenever GDB takes control, one thread in particular is 
  1297.  always the focus of debugging. This thread is called the current thread. 
  1298.  Debugging commands show program information from the perspective of the 
  1299.  current thread. 
  1300.  
  1301.  Whenever GDB detects a new thread in your program, it displays the target 
  1302.  system's identification for the thread with a message in the form `[New 
  1303.  systag]'.  systag is a thread identifier whose form varies depending on the 
  1304.  particular system.  For example, on LynxOS, you might see 
  1305.  
  1306.   [New process 35 thread 27]
  1307.  
  1308.  when GDB notices a new thread.  In contrast, on an SGI system, the systag is 
  1309.  simply something like `process 368', with no further qualifier. 
  1310.  
  1311.  For debugging purposes, GDB associates its own thread number---always a single 
  1312.  integer---with each thread in your program. 
  1313.  
  1314.  info threads 
  1315.            Display a summary of all threads currently in your program.  GDB 
  1316.            displays for each thread (in this order): 
  1317.  
  1318.              1. the thread number assigned by GDB 
  1319.  
  1320.              2. the target system's thread identifier (systag) 
  1321.  
  1322.              3. the current stack frame summary for that thread 
  1323.  
  1324.            An asterisk `*' to the left of the GDB thread number indicates the 
  1325.            current thread. 
  1326.  
  1327.            For example, 
  1328.  
  1329.   (gdb) info threads
  1330.     3 process 35 thread 27  0x34e5 in sigpause ()
  1331.     2 process 35 thread 23  0x34e5 in sigpause ()
  1332.   * 1 process 35 thread 13  main (argc=1, argv=0x7ffffff8)
  1333.       at threadtest.c:68
  1334.  
  1335.  thread threadno 
  1336.            Make thread number threadno the current thread.  The command 
  1337.            argument threadno is the internal GDB thread number, as shown in the 
  1338.            first field of the `info threads' display. GDB responds by 
  1339.            displaying the system identifier of the thread you selected, and its 
  1340.            current stack frame summary: 
  1341.  
  1342.                       (gdb) thread 2
  1343.                       [Switching to process 35 thread 23]
  1344.                       0x34e5 in sigpause ()
  1345.  
  1346.            As with the `[New ...]' message, the form of the text after 
  1347.            `Switching to' depends on your system's conventions for identifying 
  1348.            threads. 
  1349.  
  1350.  thread apply [threadno] [all]  args 
  1351.            The thread apply command allows you to apply a command to one or 
  1352.            more threads.  Specify the numbers of the threads that you want 
  1353.            affected with the command argument threadno.  threadno is the 
  1354.            internal GDB thread number, as shown in the first field of the `info 
  1355.            threads' display.  To apply a command to all threads, use thread 
  1356.            apply all args. 
  1357.  
  1358.  Whenever GDB stops your program, due to a breakpoint or a signal, it 
  1359.  automatically selects the thread where that breakpoint or signal happened. 
  1360.  GDB alerts you to the context switch with a message of the form `[Switching to 
  1361.  systag]' to identify the thread. 
  1362.  
  1363.  See Stopping and starting multi-thread programs, for more information about 
  1364.  how GDB behaves when you stop and start programs with multiple threads. 
  1365.  
  1366.  See Setting watchpoints, for information about watchpoints in programs with 
  1367.  multiple threads. 
  1368.  
  1369.  
  1370. ΓòÉΓòÉΓòÉ 7.11. Debugging programs with multiple processes ΓòÉΓòÉΓòÉ
  1371.  
  1372. GDB has no special support for debugging programs which create additional 
  1373. processes using the fork function.  When a program forks, GDB will continue to 
  1374. debug the parent process and the child process will run unimpeded.  If you have 
  1375. set a breakpoint in any code which the child then executes, the child will get 
  1376. a SIGTRAP signal which (unless it catches the signal) will cause it to 
  1377. terminate. 
  1378.  
  1379. However, if you want to debug the child process there is a workaround which 
  1380. isn't too painful.  Put a call to sleep in the code which the child process 
  1381. executes after the fork.  It may be useful to sleep only if a certain 
  1382. environment variable is set, or a certain file exists, so that the delay need 
  1383. not occur when you don't want to run GDB on the child.  While the child is 
  1384. sleeping, use the ps program to get its process ID.  Then tell GDB (a new 
  1385. invocation of GDB if you are also debugging the parent process) to attach to 
  1386. the child process (see Attach).  From that point on you can debug the child 
  1387. process just like any other process which you attached to. 
  1388.  
  1389.  
  1390. ΓòÉΓòÉΓòÉ 8. Stopping and Continuing ΓòÉΓòÉΓòÉ
  1391.  
  1392. The principal purposes of using a debugger are so that you can stop your 
  1393. program before it terminates; or so that, if your program runs into trouble, 
  1394. you can investigate and find out why. 
  1395.  
  1396. Inside GDB, your program may stop for any of several reasons, such as a signal, 
  1397. a breakpoint, or reaching a new line after a GDB command such as step.  You may 
  1398. then examine and change variables, set new breakpoints or remove old ones, and 
  1399. then continue execution.  Usually, the messages shown by GDB provide ample 
  1400. explanation of the status of your program---but you can also explicitly request 
  1401. this information at any time. 
  1402.  
  1403.  info program 
  1404.            Display information about the status of your program: whether it is 
  1405.            running or not, what process it is, and why it stopped. 
  1406.  
  1407.  Breakpoints                             Breakpoints, watchpoints, and 
  1408.                                          exceptions 
  1409.  
  1410.  Breakpoints                             Breakpoints and watchpoints 
  1411.  
  1412.  Continuing and Stepping                 Resuming execution 
  1413.  
  1414.  Signals                                 Signals 
  1415.  
  1416.  Thread Stops                            Stopping and starting multi-thread 
  1417.                                          programs 
  1418.  
  1419.  
  1420. ΓòÉΓòÉΓòÉ 8.1. Breakpoints, watchpoints, and exceptions ΓòÉΓòÉΓòÉ
  1421.  
  1422. A breakpoint makes your program stop whenever a certain point in the program is 
  1423. reached.  For each breakpoint, you can add conditions to control in finer 
  1424. detail whether your program stops. You can set breakpoints with the break 
  1425. command and its variants (see Setting breakpoints), to specify the place where 
  1426. your program should stop by line number, function name or exact address in the 
  1427. program. In languages with exception handling (such as gnu C++), you can also 
  1428. set breakpoints where an exception is raised ( see Breakpoints and exceptions). 
  1429.  
  1430. In SunOS 4.x, SVR4, and Alpha OSF/1 configurations, you can now set breakpoints 
  1431. in shared libraries before the executable is run. 
  1432.  
  1433. A watchpoint is a special breakpoint that stops your program when the value of 
  1434. an expression changes.  You must use a different command to set watchpoints ( 
  1435. see Setting watchpoints), but aside from that, you can manage a watchpoint like 
  1436. any other breakpoint: you enable, disable, and delete both breakpoints and 
  1437. watchpoints using the same commands. 
  1438.  
  1439. You can arrange to have values from your program displayed automatically 
  1440. whenever GDB stops at a breakpoint. See Automatic display. 
  1441.  
  1442. GDB assigns a number to each breakpoint or watchpoint when you create it; these 
  1443. numbers are successive integers starting with one.  In many of the commands for 
  1444. controlling various features of breakpoints you use the breakpoint number to 
  1445. say which breakpoint you want to change. Each breakpoint may be enabled or 
  1446. disabled; if disabled, it has no effect on your program until you enable it 
  1447. again. 
  1448.  
  1449.  Set Breaks                              Setting breakpoints 
  1450.  Set Watchpoints                         Setting watchpoints 
  1451.  
  1452.  Exception Handling                      Breakpoints and exceptions 
  1453.  
  1454.  Delete Breaks                           Deleting breakpoints 
  1455.  Disabling                               Disabling breakpoints 
  1456.  Conditions                              Break conditions 
  1457.  Break Commands                          Breakpoint command lists 
  1458.  
  1459.  Breakpoint Menus                        Breakpoint menus 
  1460.  
  1461.  
  1462. ΓòÉΓòÉΓòÉ 8.1.1. Setting breakpoints ΓòÉΓòÉΓòÉ
  1463.  
  1464. Breakpoints are set with the break command (abbreviated b).  The debugger 
  1465. convenience variable `$bpnum' records the number of the breakpoints you've set 
  1466. most recently; see Convenience variables, for a discussion of what you can do 
  1467. with convenience variables. 
  1468.  
  1469. You have several ways to say where the breakpoint should go. 
  1470.  
  1471.  break function 
  1472.            Set a breakpoint at entry to function function. When using source 
  1473.            languages that permit overloading of symbols, such as C++, function 
  1474.            may refer to more than one possible place to break. See Breakpoint 
  1475.            menus, for a discussion of that situation. 
  1476.  
  1477.  break +offset 
  1478.  break -offset 
  1479.            Set a breakpoint some number of lines forward or back from the 
  1480.            position at which execution stopped in the currently selected frame. 
  1481.  
  1482.  break linenum 
  1483.            Set a breakpoint at line linenum in the current source file. That 
  1484.            file is the last file whose source text was printed.  This 
  1485.            breakpoint stops your program just before it executes any of the 
  1486.            code on that line. 
  1487.  
  1488.  break filename:linenum 
  1489.            Set a breakpoint at line linenum in source file filename. 
  1490.  
  1491.  break filename:function 
  1492.            Set a breakpoint at entry to function function found in file 
  1493.            filename.  Specifying a file name as well as a function name is 
  1494.            superfluous except when multiple files contain similarly named 
  1495.            functions. 
  1496.  
  1497.  break *address 
  1498.            Set a breakpoint at address address.  You can use this to set 
  1499.            breakpoints in parts of your program which do not have debugging 
  1500.            information or source files. 
  1501.  
  1502.  break 
  1503.            When called without any arguments, break sets a breakpoint at the 
  1504.            next instruction to be executed in the selected stack frame (see 
  1505.            Examining the Stack).  In any selected frame but the innermost, this 
  1506.            makes your program stop as soon as control returns to that frame. 
  1507.            This is similar to the effect of a finish command in the frame 
  1508.            inside the selected frame---except that finish does not leave an 
  1509.            active breakpoint.  If you use break without an argument in the 
  1510.            innermost frame, GDB stops the next time it reaches the current 
  1511.            location; this may be useful inside loops. 
  1512.  
  1513.            GDB normally ignores breakpoints when it resumes execution, until at 
  1514.            least one instruction has been executed.  If it did not do this, you 
  1515.            would be unable to proceed past a breakpoint without first disabling 
  1516.            the breakpoint.  This rule applies whether or not the breakpoint 
  1517.            already existed when your program stopped. 
  1518.  
  1519.  break ... if cond 
  1520.            Set a breakpoint with condition cond; evaluate the expression cond 
  1521.            each time the breakpoint is reached, and stop only if the value is 
  1522.            nonzero---that is, if cond evaluates as true. `...' stands for one 
  1523.            of the possible arguments described above (or no argument) 
  1524.            specifying where to break. See Break conditions, for more 
  1525.            information on breakpoint conditions. 
  1526.  
  1527.  tbreak args 
  1528.            Set a breakpoint enabled only for one stop.  args are the same as 
  1529.            for the break command, and the breakpoint is set in the same way, 
  1530.            but the breakpoint is automatically deleted after the first time 
  1531.            your program stops there.  See Disabling breakpoints. 
  1532.  
  1533.  hbreak args 
  1534.            Set a hardware-assisted breakpoint.  args are the same as for the 
  1535.            break command and the breakpoint is set in the same way, but the 
  1536.            breakpoint requires hardware support and some target hardware may 
  1537.            not have this support.  The main purpose of this is EPROM/ROM code 
  1538.            debugging, so you can set a breakpoint at an instruction without 
  1539.            changing the instruction.  This can be used with the new 
  1540.            trap-generation provided by SPARClite DSU.  DSU will generate traps 
  1541.            when a program accesses some date or instruction address that is 
  1542.            assigned to the debug registers. However the hardware breakpoint 
  1543.            registers can only take two data breakpoints, and GDB will reject 
  1544.            this command if more than two are used. Delete or disable usused 
  1545.            hardware breakpoints before setting new ones.  See Break conditions. 
  1546.  
  1547.  thbreak args 
  1548.            Set a hardware-assisted breakpoint enabled only for one stop.  args 
  1549.            are the same as for the hbreak command and the breakpoint is set in 
  1550.            the same way.  However, like the tbreak command, the breakpoint is 
  1551.            automatically deleted after the first time your program stops there. 
  1552.            Also, like the hbreak command, the breakpoint requires hardware 
  1553.            support and some target hardware may not have this support.  See 
  1554.            Disabling breakpoints. Also See Break conditions. 
  1555.  
  1556.  rbreak regex 
  1557.            Set breakpoints on all functions matching the regular expression 
  1558.            regex.  This command sets an unconditional breakpoint on all 
  1559.            matches, printing a list of all breakpoints it set.  Once these 
  1560.            breakpoints are set, they are treated just like the breakpoints set 
  1561.            with the break command.  You can delete them, disable them, or make 
  1562.            them conditional the same way as any other breakpoint. 
  1563.  
  1564.            When debugging C++ programs, rbreak is useful for setting 
  1565.            breakpoints on overloaded functions that are not members of any 
  1566.            special classes. 
  1567.  
  1568.  info breakpoints [n] 
  1569.  info break [n] 
  1570.  info watchpoints [n] 
  1571.            Print a table of all breakpoints and watchpoints set and not 
  1572.            deleted, with the following columns for each breakpoint: 
  1573.  
  1574.            Breakpoint Numbers 
  1575.  
  1576.            Type 
  1577.                           Breakpoint or watchpoint. 
  1578.  
  1579.            Disposition 
  1580.                           Whether the breakpoint is marked to be disabled or 
  1581.                           deleted when hit. 
  1582.  
  1583.            Enabled or Disabled 
  1584.                           Enabled breakpoints are marked with `y'.  `n' marks 
  1585.                           breakpoints that are not enabled. 
  1586.  
  1587.            Address 
  1588.                           Where the breakpoint is in your program, as a memory 
  1589.                           address 
  1590.  
  1591.            What 
  1592.                           Where the breakpoint is in the source for your 
  1593.                           program, as a file and line number. 
  1594.  
  1595.            If a breakpoint is conditional, info break shows the condition on 
  1596.            the line following the affected breakpoint; breakpoint commands, if 
  1597.            any, are listed after that. 
  1598.  
  1599.            info break with a breakpoint number n as argument lists only that 
  1600.            breakpoint.  The convenience variable $_ and the default 
  1601.            examining-address for the x command are set to the address of the 
  1602.            last breakpoint listed (see Examining memory). 
  1603.  
  1604.            info break now displays a count of the number of times the 
  1605.            breakpoint has been hit.  This is especially useful in conjunction 
  1606.            with the ignore command.  You can ignore a large number of 
  1607.            breakpoint hits, look at the breakpoint info to see how many times 
  1608.            the breakpoint was hit, and then run again, ignoring one less than 
  1609.            that number.  This will get you quickly to the last hit of that 
  1610.            breakpoint. 
  1611.  
  1612.  GDB allows you to set any number of breakpoints at the same place in your 
  1613.  program.  There is nothing silly or meaningless about this.  When the 
  1614.  breakpoints are conditional, this is even useful (see Break conditions). 
  1615.  
  1616.  GDB itself sometimes sets breakpoints in your program for special purposes, 
  1617.  such as proper handling of longjmp (in C programs). These internal breakpoints 
  1618.  are assigned negative numbers, starting with -1; `info breakpoints' does not 
  1619.  display them. 
  1620.  
  1621.  You can see these breakpoints with the GDB maintenance command `maint info 
  1622.  breakpoints'. 
  1623.  
  1624.  maint info breakpoints 
  1625.            Using the same format as `info breakpoints', display both the 
  1626.            breakpoints you've set explicitly, and those GDB is using for 
  1627.            internal purposes.  Internal breakpoints are shown with negative 
  1628.            breakpoint numbers.  The type column identifies what kind of 
  1629.            breakpoint is shown: 
  1630.  
  1631.            breakpoint 
  1632.                           Normal, explicitly set breakpoint. 
  1633.  
  1634.            watchpoint 
  1635.                           Normal, explicitly set watchpoint. 
  1636.  
  1637.            longjmp 
  1638.                           Internal breakpoint, used to handle correctly 
  1639.                           stepping through longjmp calls. 
  1640.  
  1641.            longjmp resume 
  1642.                           Internal breakpoint at the target of a longjmp. 
  1643.  
  1644.            until 
  1645.                           Temporary internal breakpoint used by the GDB until 
  1646.                           command. 
  1647.  
  1648.            finish 
  1649.                           Temporary internal breakpoint used by the GDB finish 
  1650.                           command. 
  1651.  
  1652.  
  1653. ΓòÉΓòÉΓòÉ 8.1.2. Setting watchpoints ΓòÉΓòÉΓòÉ
  1654.  
  1655. You can use a watchpoint to stop execution whenever the value of an expression 
  1656. changes, without having to predict a particular place where this may happen. 
  1657.  
  1658. Watchpoints currently execute two orders of magnitude more slowly than other 
  1659. breakpoints, but this can be well worth it to catch errors where you have no 
  1660. clue what part of your program is the culprit. 
  1661.  
  1662.  watch expr 
  1663.            Set a watchpoint for an expression.  GDB will break when expr is 
  1664.            written into by the program and its value changes. This can be used 
  1665.            with the new trap-generation provided by SPARClite DSU.  DSU will 
  1666.            generate traps when a program accesses some date or instruction 
  1667.            address that is assigned to the debug registers. For the data 
  1668.            addresses, DSU facilitates the watch command. However the hardware 
  1669.            breakpoint registers can only take two data watchpoints, and both 
  1670.            watchpoints must be the same kind.  For example, you can set two 
  1671.            watchpoints with watch commands, two with rwatch commands, *or* two 
  1672.            with awatch commands, but you cannot set one watchpoint with one 
  1673.            command and the other with a different command.  will reject the 
  1674.            command if you try to mix watchpoints. Delete or disable unused 
  1675.            watchpoint commands before setting new ones. 
  1676.  
  1677.  rwatch expr 
  1678.            Set a watchpoint that will break when watch args is read by the 
  1679.            program. If you use both watchpoints, both must be set with the 
  1680.            rwatch command. 
  1681.  
  1682.  awatch expr 
  1683.            Set a watchpoint that will break when args is read and written into 
  1684.            by the program.  If you use both watchpoints, both must be set with 
  1685.            the awatch command. 
  1686.  
  1687.  info watchpoints 
  1688.            This command prints a list of watchpoints and breakpoints; it is the 
  1689.            same as info break. 
  1690.  
  1691.  Warning: in multi-thread programs, watchpoints have only limited usefulness. 
  1692.  With the current watchpoint implementation, GDB can only watch the value of an 
  1693.  expression in a single thread.  If you are confident that the expression can 
  1694.  only change due to the current thread's activity (and if you are also 
  1695.  confident that no other thread can become current), then you can use 
  1696.  watchpoints as usual.  However, GDB may not notice when a non-current thread's 
  1697.  activity changes the expression. 
  1698.  
  1699.  
  1700. ΓòÉΓòÉΓòÉ 8.1.3. Breakpoints and exceptions ΓòÉΓòÉΓòÉ
  1701.  
  1702. Some languages, such as gnu C++, implement exception handling.  You can use GDB 
  1703. to examine what caused your program to raise an exception, and to list the 
  1704. exceptions your program is prepared to handle at a given point in time. 
  1705.  
  1706.  catch exceptions 
  1707.            You can set breakpoints at active exception handlers by using the 
  1708.            catch command.  exceptions is a list of names of exceptions to 
  1709.            catch. 
  1710.  
  1711.  You can use info catch to list active exception handlers. See Information 
  1712.  about a frame. 
  1713.  
  1714.  There are currently some limitations to exception handling in GDB: 
  1715.  
  1716.      If you call a function interactively, GDB normally returns control to you 
  1717.       when the function has finished executing.  If the call raises an 
  1718.       exception, however, the call may bypass the mechanism that returns 
  1719.       control to you and cause your program to simply continue running until it 
  1720.       hits a breakpoint, catches a signal that GDB is listening for, or exits. 
  1721.  
  1722.      You cannot raise an exception interactively. 
  1723.  
  1724.      You cannot install an exception handler interactively. 
  1725.  
  1726.  Sometimes catch is not the best way to debug exception handling: if you need 
  1727.  to know exactly where an exception is raised, it is better to stop before the 
  1728.  exception handler is called, since that way you can see the stack before any 
  1729.  unwinding takes place.  If you set a breakpoint in an exception handler 
  1730.  instead, it may not be easy to find out where the exception was raised. 
  1731.  
  1732.  To stop just before an exception handler is called, you need some knowledge of 
  1733.  the implementation.  In the case of gnu C++, exceptions are raised by calling 
  1734.  a library function named __raise_exception which has the following ANSI C 
  1735.  interface: 
  1736.  
  1737.       /* addr is where the exception identifier is stored.
  1738.          ID is the exception identifier.  */
  1739.       void __raise_exception (void **addr, void *id);
  1740.  
  1741.  To make the debugger catch all exceptions before any stack unwinding takes 
  1742.  place, set a breakpoint on __raise_exception (see Breakpoints; watchpoints; 
  1743.  and exceptions). 
  1744.  
  1745.  With a conditional breakpoint (see Break conditions) that depends on the value 
  1746.  of id, you can stop your program when a specific exception is raised.  You can 
  1747.  use multiple conditional breakpoints to stop your program when any of a number 
  1748.  of exceptions are raised. 
  1749.  
  1750.  
  1751. ΓòÉΓòÉΓòÉ 8.1.4. Deleting breakpoints ΓòÉΓòÉΓòÉ
  1752.  
  1753. It is often necessary to eliminate a breakpoint or watchpoint once it has done 
  1754. its job and you no longer want your program to stop there.  This is called 
  1755. deleting the breakpoint.  A breakpoint that has been deleted no longer exists; 
  1756. it is forgotten. 
  1757.  
  1758. With the clear command you can delete breakpoints according to where they are 
  1759. in your program.  With the delete command you can delete individual breakpoints 
  1760. or watchpoints by specifying their breakpoint numbers. 
  1761.  
  1762. It is not necessary to delete a breakpoint to proceed past it.  GDB 
  1763. automatically ignores breakpoints on the first instruction to be executed when 
  1764. you continue execution without changing the execution address. 
  1765.  
  1766.  clear 
  1767.            Delete any breakpoints at the next instruction to be executed in the 
  1768.            selected stack frame (see Selecting a frame).  When the innermost 
  1769.            frame is selected, this is a good way to delete a breakpoint where 
  1770.            your program just stopped. 
  1771.  
  1772.  clear function 
  1773.  clear filename:function 
  1774.            Delete any breakpoints set at entry to the function function. 
  1775.  
  1776.  clear linenum 
  1777.  clear filename:linenum 
  1778.            Delete any breakpoints set at or within the code of the specified 
  1779.            line. 
  1780.  
  1781.  delete [breakpoints] [bnums...] 
  1782.            Delete the breakpoints or watchpoints of the numbers specified as 
  1783.            arguments.  If no argument is specified, delete all breakpoints (GDB 
  1784.            asks confirmation, unless you have set confirm off).  You can 
  1785.            abbreviate this command as d. 
  1786.  
  1787.  
  1788. ΓòÉΓòÉΓòÉ 8.1.5. Disabling breakpoints ΓòÉΓòÉΓòÉ
  1789.  
  1790. Rather than deleting a breakpoint or watchpoint, you might prefer to disable 
  1791. it.  This makes the breakpoint inoperative as if it had been deleted, but 
  1792. remembers the information on the breakpoint so that you can enable it again 
  1793. later. 
  1794.  
  1795. You disable and enable breakpoints and watchpoints with the enable and disable 
  1796. commands, optionally specifying one or more breakpoint numbers as arguments. 
  1797. Use info break or info watch to print a list of breakpoints or watchpoints if 
  1798. you do not know which numbers to use. 
  1799.  
  1800. A breakpoint or watchpoint can have any of four different states of enablement: 
  1801.  
  1802.      Enabled.  The breakpoint stops your program.  A breakpoint set with the 
  1803.       break command starts out in this state. 
  1804.  
  1805.      Disabled.  The breakpoint has no effect on your program. 
  1806.  
  1807.      Enabled once.  The breakpoint stops your program, but then becomes 
  1808.       disabled.  A breakpoint set with the tbreak command starts out in this 
  1809.       state. 
  1810.  
  1811.      Enabled for deletion.  The breakpoint stops your program, but immediately 
  1812.       after it does so it is deleted permanently. 
  1813.  
  1814.  You can use the following commands to enable or disable breakpoints and 
  1815.  watchpoints: 
  1816.  
  1817.  disable [breakpoints] [bnums...] 
  1818.            Disable the specified breakpoints---or all breakpoints, if none are 
  1819.            listed.  A disabled breakpoint has no effect but is not forgotten. 
  1820.            All options such as ignore-counts, conditions and commands are 
  1821.            remembered in case the breakpoint is enabled again later.  You may 
  1822.            abbreviate disable as dis. 
  1823.  
  1824.  enable [breakpoints] [bnums...] 
  1825.            Enable the specified breakpoints (or all defined breakpoints).  They 
  1826.            become effective once again in stopping your program. 
  1827.  
  1828.  enable [breakpoints] once bnums... 
  1829.            Enable the specified breakpoints temporarily.  GDB disables any of 
  1830.            these breakpoints immediately after stopping your program. 
  1831.  
  1832.  enable [breakpoints] delete bnums... 
  1833.            Enable the specified breakpoints to work once, then die.  GDB 
  1834.            deletes any of these breakpoints as soon as your program stops 
  1835.            there. 
  1836.  
  1837.  Except for a breakpoint set with tbreak ( see Setting breakpoints), 
  1838.  breakpoints that you set are initially enabled; subsequently, they become 
  1839.  disabled or enabled only when you use one of the commands above.  (The command 
  1840.  until can set and delete a breakpoint of its own, but it does not change the 
  1841.  state of your other breakpoints; see Continuing and stepping.) 
  1842.  
  1843.  
  1844. ΓòÉΓòÉΓòÉ 8.1.6. Break conditions ΓòÉΓòÉΓòÉ
  1845.  
  1846. The simplest sort of breakpoint breaks every time your program reaches a 
  1847. specified place.  You can also specify a condition for a breakpoint.  A 
  1848. condition is just a Boolean expression in your programming language (see 
  1849. Expressions).  A breakpoint with a condition evaluates the expression each time 
  1850. your program reaches it, and your program stops only if the condition is true. 
  1851.  
  1852. This is the converse of using assertions for program validation; in that 
  1853. situation, you want to stop when the assertion is violated---that is, when the 
  1854. condition is false.  In C, if you want to test an assertion expressed by the 
  1855. condition assert, you should set the condition `! assert' on the appropriate 
  1856. breakpoint. 
  1857.  
  1858. Conditions are also accepted for watchpoints; you may not need them, since a 
  1859. watchpoint is inspecting the value of an expression anyhow---but it might be 
  1860. simpler, say, to just set a watchpoint on a variable name, and specify a 
  1861. condition that tests whether the new value is an interesting one. 
  1862.  
  1863. Break conditions can have side effects, and may even call functions in your 
  1864. program.  This can be useful, for example, to activate functions that log 
  1865. program progress, or to use your own print functions to format special data 
  1866. structures. The effects are completely predictable unless there is another 
  1867. enabled breakpoint at the same address.  (In that case, GDB might see the other 
  1868. breakpoint first and stop your program without checking the condition of this 
  1869. one.)  Note that breakpoint commands are usually more convenient and flexible 
  1870. for the purpose of performing side effects when a breakpoint is reached (see 
  1871. Breakpoint command lists). 
  1872.  
  1873. Break conditions can be specified when a breakpoint is set, by using `if' in 
  1874. the arguments to the break command. See Setting breakpoints.  They can also be 
  1875. changed at any time with the condition command.  The watch command does not 
  1876. recognize the if keyword; condition is the only way to impose a further 
  1877. condition on a watchpoint. 
  1878.  
  1879.  condition bnum expression 
  1880.            Specify expression as the break condition for breakpoint or 
  1881.            watchpoint number bnum.  After you set a condition, breakpoint bnum 
  1882.            stops your program only if the value of expression is true (nonzero, 
  1883.            in C).  When you use condition, GDB checks expression immediately 
  1884.            for syntactic correctness, and to determine whether symbols in it 
  1885.            have referents in the context of your breakpoint. GDB does not 
  1886.            actually evaluate expression at the time the condition command is 
  1887.            given, however.  See Expressions. 
  1888.  
  1889.  condition bnum 
  1890.            Remove the condition from breakpoint number bnum.  It becomes an 
  1891.            ordinary unconditional breakpoint. 
  1892.  
  1893.  A special case of a breakpoint condition is to stop only when the breakpoint 
  1894.  has been reached a certain number of times.  This is so useful that there is a 
  1895.  special way to do it, using the ignore count of the breakpoint.  Every 
  1896.  breakpoint has an ignore count, which is an integer.  Most of the time, the 
  1897.  ignore count is zero, and therefore has no effect.  But if your program 
  1898.  reaches a breakpoint whose ignore count is positive, then instead of stopping, 
  1899.  it just decrements the ignore count by one and continues.  As a result, if the 
  1900.  ignore count value is n, the breakpoint does not stop the next n times your 
  1901.  program reaches it. 
  1902.  
  1903.  ignore bnum count 
  1904.            Set the ignore count of breakpoint number bnum to count. The next 
  1905.            count times the breakpoint is reached, your program's execution does 
  1906.            not stop; other than to decrement the ignore count, GDB takes no 
  1907.            action. 
  1908.  
  1909.            To make the breakpoint stop the next time it is reached, specify a 
  1910.            count of zero. 
  1911.  
  1912.            When you use continue to resume execution of your program from a 
  1913.            breakpoint, you can specify an ignore count directly as an argument 
  1914.            to continue, rather than using ignore. See Continuing and stepping. 
  1915.  
  1916.            If a breakpoint has a positive ignore count and a condition, the 
  1917.            condition is not checked.  Once the ignore count reaches zero, GDB 
  1918.            resumes checking the condition. 
  1919.  
  1920.            You could achieve the effect of the ignore count with a condition 
  1921.            such as `$foo-- <= 0' using a debugger convenience variable that is 
  1922.            decremented each time. See Convenience variables. 
  1923.  
  1924.  
  1925. ΓòÉΓòÉΓòÉ 8.1.7. Breakpoint command lists ΓòÉΓòÉΓòÉ
  1926.  
  1927. You can give any breakpoint (or watchpoint) a series of commands to execute 
  1928. when your program stops due to that breakpoint.  For example, you might want to 
  1929. print the values of certain expressions, or enable other breakpoints. 
  1930.  
  1931.  commands [bnum] 
  1932.  ... command-list ... 
  1933.  end 
  1934.            Specify a list of commands for breakpoint number bnum.  The commands 
  1935.            themselves appear on the following lines.  Type a line containing 
  1936.            just end to terminate the commands. 
  1937.  
  1938.            To remove all commands from a breakpoint, type commands and follow 
  1939.            it immediately with end; that is, give no commands. 
  1940.  
  1941.            With no bnum argument, commands refers to the last breakpoint or 
  1942.            watchpoint set (not to the breakpoint most recently encountered). 
  1943.  
  1944.  Pressing RET as a means of repeating the last GDB command is disabled within a 
  1945.  command-list. 
  1946.  
  1947.  You can use breakpoint commands to start your program up again.  Simply use 
  1948.  the continue command, or step, or any other command that resumes execution. 
  1949.  
  1950.  Any other commands in the command list, after a command that resumes 
  1951.  execution, are ignored.  This is because any time you resume execution (even 
  1952.  with a simple next or step), you may encounter another breakpoint---which 
  1953.  could have its own command list, leading to ambiguities about which list to 
  1954.  execute. 
  1955.  
  1956.  If the first command you specify in a command list is silent, the usual 
  1957.  message about stopping at a breakpoint is not printed.  This may be desirable 
  1958.  for breakpoints that are to print a specific message and then continue.  If 
  1959.  none of the remaining commands print anything, you see no sign that the 
  1960.  breakpoint was reached.  silent is meaningful only at the beginning of a 
  1961.  breakpoint command list. 
  1962.  
  1963.  The commands echo, output, and printf allow you to print precisely controlled 
  1964.  output, and are often useful in silent breakpoints.  See Commands for 
  1965.  controlled output. 
  1966.  
  1967.  For example, here is how you could use breakpoint commands to print the value 
  1968.  of x at entry to foo whenever x is positive. 
  1969.  
  1970.   break foo if x>0
  1971.   commands
  1972.   silent
  1973.   printf "x is %d\n",x
  1974.   cont
  1975.   end
  1976.  
  1977.  One application for breakpoint commands is to compensate for one bug so you 
  1978.  can test for another.  Put a breakpoint just after the erroneous line of code, 
  1979.  give it a condition to detect the case in which something erroneous has been 
  1980.  done, and give it commands to assign correct values to any variables that need 
  1981.  them.  End with the continue command so that your program does not stop, and 
  1982.  start with the silent command so that no output is produced.  Here is an 
  1983.  example: 
  1984.  
  1985.   break 403
  1986.   commands
  1987.   silent
  1988.   set x = y + 4
  1989.   cont
  1990.   end
  1991.  
  1992.  
  1993. ΓòÉΓòÉΓòÉ 8.1.8. Breakpoint menus ΓòÉΓòÉΓòÉ
  1994.  
  1995. Some programming languages (notably C++) permit a single function name to be 
  1996. defined several times, for application in different contexts. This is called 
  1997. overloading.  When a function name is overloaded, `break function' is not 
  1998. enough to tell GDB where you want a breakpoint.  If you realize this is a 
  1999. problem, you can use something like `break function(types)' to specify which 
  2000. particular version of the function you want.  Otherwise, GDB offers you a menu 
  2001. of numbered choices for different possible breakpoints, and waits for your 
  2002. selection with the prompt `>'.  The first two options are always `[0] cancel' 
  2003. and `[1] all'.  Typing 1 sets a breakpoint at each definition of function, and 
  2004. typing 0 aborts the break command without setting any new breakpoints. 
  2005.  
  2006. For example, the following session excerpt shows an attempt to set a breakpoint 
  2007. at the overloaded symbol String::after. We choose three particular definitions 
  2008. of that function name: 
  2009.  
  2010. (gdb) b String::after
  2011. [0] cancel
  2012. [1] all
  2013. [2] file:String.cc; line number:867
  2014. [3] file:String.cc; line number:860
  2015. [4] file:String.cc; line number:875
  2016. [5] file:String.cc; line number:853
  2017. [6] file:String.cc; line number:846
  2018. [7] file:String.cc; line number:735
  2019. > 2 4 6
  2020. Breakpoint 1 at 0xb26c: file String.cc, line 867.
  2021. Breakpoint 2 at 0xb344: file String.cc, line 875.
  2022. Breakpoint 3 at 0xafcc: file String.cc, line 846.
  2023. Multiple breakpoints were set.
  2024. Use the "delete" command to delete unwanted
  2025.  breakpoints.
  2026. (gdb)
  2027.  
  2028.  
  2029. ΓòÉΓòÉΓòÉ 8.2. Continuing and stepping ΓòÉΓòÉΓòÉ
  2030.  
  2031. Continuing means resuming program execution until your program completes 
  2032. normally.  In contrast, stepping means executing just one more ``step'' of your 
  2033. program, where ``step'' may mean either one line of source code, or one machine 
  2034. instruction (depending on what particular command you use).  Either when 
  2035. continuing or when stepping, your program may stop even sooner, due to a 
  2036. breakpoint or a signal.  (If due to a signal, you may want to use handle, or 
  2037. use `signal 0' to resume execution. See Signals.) 
  2038.  
  2039.  continue [ignore-count] 
  2040.  c [ignore-count] 
  2041.  fg [ignore-count] 
  2042.            Resume program execution, at the address where your program last 
  2043.            stopped; any breakpoints set at that address are bypassed.  The 
  2044.            optional argument ignore-count allows you to specify a further 
  2045.            number of times to ignore a breakpoint at this location; its effect 
  2046.            is like that of ignore (see Break conditions). 
  2047.  
  2048.            The argument ignore-count is meaningful only when your program 
  2049.            stopped due to a breakpoint.  At other times, the argument to 
  2050.            continue is ignored. 
  2051.  
  2052.            The synonyms c and fg are provided purely for convenience, and have 
  2053.            exactly the same behavior as continue. 
  2054.  
  2055.  To resume execution at a different place, you can use return (see Returning 
  2056.  from a function) to go back to the calling function; or jump ( see Continuing 
  2057.  at a different address) to go to an arbitrary location in your program. 
  2058.  
  2059.  A typical technique for using stepping is to set a breakpoint (see 
  2060.  Breakpoints; watchpoints; and exceptions) at the beginning of the function or 
  2061.  the section of your program where a problem is believed to lie, run your 
  2062.  program until it stops at that breakpoint, and then step through the suspect 
  2063.  area, examining the variables that are interesting, until you see the problem 
  2064.  happen. 
  2065.  
  2066.  step 
  2067.            Continue running your program until control reaches a different 
  2068.            source line, then stop it and return control to GDB.  This command 
  2069.            is abbreviated s. 
  2070.  
  2071.            Warning: If you use the step command while control is within a 
  2072.            function that was compiled without debugging information, execution 
  2073.            proceeds until control reaches a function that does have debugging 
  2074.            information.  Likewise, it will not step into a function which is 
  2075.            compiled without debugging information.  To step through functions 
  2076.            without debugging information, use the stepi command, described 
  2077.            below. 
  2078.  
  2079.            The step command now only stops at the first instruction of a source 
  2080.            line.  This prevents the multiple stops that used to occur in switch 
  2081.            statements, for loops, etc.  step continues to stop if a function 
  2082.            that has debugging information is called within the line. 
  2083.  
  2084.            Also, the step command now only enters a subroutine if there is line 
  2085.            number information for the subroutine.  Otherwise it acts like the 
  2086.            next command.  This avoids problems when using cc -gl on MIPS 
  2087.            machines.  Previously, step entered subroutines if there was any 
  2088.            debugging information about the routine. 
  2089.  
  2090.  step count 
  2091.            Continue running as in step, but do so count times.  If a breakpoint 
  2092.            is reached, or a signal not related to stepping occurs before count 
  2093.            steps, stepping stops right away. 
  2094.  
  2095.  next [count] 
  2096.            Continue to the next source line in the current (innermost) stack 
  2097.            frame. This is similar to step, but function calls that appear 
  2098.            within the line of code are executed without stopping.  Execution 
  2099.            stops when control reaches a different line of code at the original 
  2100.            stack level that was executing when you gave the next command.  This 
  2101.            command is abbreviated n. 
  2102.  
  2103.            An argument count is a repeat count, as for step. 
  2104.  
  2105.            The next command now only stops at the first instruction of a source 
  2106.            line.  This prevents the multiple stops that used to occur in swtch 
  2107.            statements, for loops, etc. 
  2108.  
  2109.  finish 
  2110.            Continue running until just after function in the selected stack 
  2111.            frame returns.  Print the returned value (if any). 
  2112.  
  2113.            Contrast this with the return command ( see Returning from a 
  2114.            function). 
  2115.            u 
  2116.  
  2117.  until 
  2118.            Continue running until a source line past the current line, in the 
  2119.            current stack frame, is reached.  This command is used to avoid 
  2120.            single stepping through a loop more than once.  It is like the next 
  2121.            command, except that when until encounters a jump, it automatically 
  2122.            continues execution until the program counter is greater than the 
  2123.            address of the jump. 
  2124.  
  2125.            This means that when you reach the end of a loop after single 
  2126.            stepping though it, until makes your program continue execution 
  2127.            until it exits the loop.  In contrast, a next command at the end of 
  2128.            a loop simply steps back to the beginning of the loop, which forces 
  2129.            you to step through the next iteration. 
  2130.  
  2131.            until always stops your program if it attempts to exit the current 
  2132.            stack frame. 
  2133.  
  2134.            until may produce somewhat counterintuitive results if the order of 
  2135.            machine code does not match the order of the source lines.  For 
  2136.            example, in the following excerpt from a debugging session, the f 
  2137.            (frame) command shows that execution is stopped at line 206; yet 
  2138.            when we use until, we get to line 195: 
  2139.  
  2140.                       (gdb) f
  2141.                       #0  main (argc=4, argv=0xf7fffae8) at m4.c:206
  2142.                       206                 expand_input();
  2143.                       (gdb) until
  2144.                       195             for ( ; argc > 0; NEXTARG) {
  2145.  
  2146.            This happened because, for execution efficiency, the compiler had 
  2147.            generated code for the loop closure test at the end, rather than the 
  2148.            start, of the loop---even though the test in a C for-loop is written 
  2149.            before the body of the loop.  The until command appeared to step 
  2150.            back to the beginning of the loop when it advanced to this 
  2151.            expression; however, it has not really gone to an earlier 
  2152.            statement---not in terms of the actual machine code. 
  2153.  
  2154.            until with no argument works by means of single instruction 
  2155.            stepping, and hence is slower than until with an argument. 
  2156.  
  2157.  until location 
  2158.  u location 
  2159.            Continue running your program until either the specified location is 
  2160.            reached, or the current stack frame returns.  location is any of the 
  2161.            forms of argument acceptable to break ( see Setting breakpoints). 
  2162.            This form of the command uses breakpoints, and hence is quicker than 
  2163.            until without an argument. 
  2164.  
  2165.  stepi 
  2166.  si 
  2167.            Execute one machine instruction, then stop and return to the 
  2168.            debugger. 
  2169.  
  2170.            It is often useful to do `display/i $pc' when stepping by machine 
  2171.            instructions.  This makes GDB automatically display the next 
  2172.            instruction to be executed, each time your program stops. See 
  2173.            Automatic display. 
  2174.  
  2175.            An argument is a repeat count, as in step. 
  2176.  
  2177.  nexti 
  2178.  ni 
  2179.            Execute one machine instruction, but if it is a function call, 
  2180.            proceed until the function returns. 
  2181.  
  2182.            An argument is a repeat count, as in next. 
  2183.  
  2184.  
  2185. ΓòÉΓòÉΓòÉ 8.3. Signals ΓòÉΓòÉΓòÉ
  2186.  
  2187. A signal is an asynchronous event that can happen in a program.  The operating 
  2188. system defines the possible kinds of signals, and gives each kind a name and a 
  2189. number.  For example, in Unix SIGINT is the signal a program gets when you type 
  2190. an interrupt (often C-c); SIGSEGV is the signal a program gets from referencing 
  2191. a place in memory far away from all the areas in use; SIGALRM occurs when the 
  2192. alarm clock timer goes off (which happens only if your program has requested an 
  2193. alarm). 
  2194.  
  2195. Some signals, including SIGALRM, are a normal part of the functioning of your 
  2196. program.  Others, such as SIGSEGV, indicate errors; these signals are fatal 
  2197. (kill your program immediately) if the program has not specified in advance 
  2198. some other way to handle the signal. SIGINT does not indicate an error in your 
  2199. program, but it is normally fatal so it can carry out the purpose of the 
  2200. interrupt: to kill the program. 
  2201.  
  2202. GDB has the ability to detect any occurrence of a signal in your program.  You 
  2203. can tell GDB in advance what to do for each kind of signal. 
  2204.  
  2205. Normally, GDB is set up to ignore non-erroneous signals like SIGALRM (so as not 
  2206. to interfere with their role in the functioning of your program) but to stop 
  2207. your program immediately whenever an error signal happens. You can change these 
  2208. settings with the handle command. 
  2209.  
  2210.  info signals 
  2211.            Print a table of all the kinds of signals and how GDB has been told 
  2212.            to handle each one.  You can use this to see the signal numbers of 
  2213.            all the defined types of signals. 
  2214.  
  2215.            info handle is the new alias for info signals. 
  2216.  
  2217.  handle signal keywords... 
  2218.            Change the way GDB handles signal signal.  signal can be the number 
  2219.            of a signal or its name (with or without the `SIG' at the 
  2220.            beginning).  The keywords say what change to make. 
  2221.  
  2222.  The keywords allowed by the handle command can be abbreviated. Their full 
  2223.  names are: 
  2224.  
  2225.  nostop 
  2226.            GDB should not stop your program when this signal happens.  It may 
  2227.            still print a message telling you that the signal has come in. 
  2228.  
  2229.  stop 
  2230.            GDB should stop your program when this signal happens.  This implies 
  2231.            the print keyword as well. 
  2232.  
  2233.  print 
  2234.            GDB should print a message when this signal happens. 
  2235.  
  2236.  noprint 
  2237.            GDB should not mention the occurrence of the signal at all.  This 
  2238.            implies the nostop keyword as well. 
  2239.  
  2240.  pass 
  2241.            GDB should allow your program to see this signal; your program can 
  2242.            handle the signal, or else it may terminate if the signal is fatal 
  2243.            and not handled. 
  2244.  
  2245.  nopass 
  2246.            GDB should not allow your program to see this signal. 
  2247.  
  2248.  When a signal stops your program, the signal is not visible until you 
  2249.  continue.  Your program sees the signal then, if pass is in effect for the 
  2250.  signal in question at that time.  In other words, after GDB reports a signal, 
  2251.  you can use the handle command with pass or nopass to control whether your 
  2252.  program sees that signal when you continue. 
  2253.  
  2254.  You can also use the signal command to prevent your program from seeing a 
  2255.  signal, or cause it to see a signal it normally would not see, or to give it 
  2256.  any signal at any time.  For example, if your program stopped due to some sort 
  2257.  of memory reference error, you might store correct values into the erroneous 
  2258.  variables and continue, hoping to see more execution; but your program would 
  2259.  probably terminate immediately as a result of the fatal signal once it saw the 
  2260.  signal.  To prevent this, you can continue with `signal 0'. See Giving your 
  2261.  program a signal. 
  2262.  
  2263.  
  2264. ΓòÉΓòÉΓòÉ 8.4. Stopping and starting multi-thread programs ΓòÉΓòÉΓòÉ
  2265.  
  2266. When your program has multiple threads ( see Debugging programs with multiple 
  2267. threads), you can choose whether to set breakpoints on all threads, or on a 
  2268. particular thread. 
  2269.  
  2270.  break linespec thread threadno 
  2271.  break linespec thread threadno if ... 
  2272.            linespec specifies source lines; there are several ways of writing 
  2273.            them, but the effect is always to specify some source line. 
  2274.  
  2275.            Use the qualifier `thread threadno' with a breakpoint command to 
  2276.            specify that you only want GDB to stop the program when a particular 
  2277.            thread reaches this breakpoint.  threadno is one of the numeric 
  2278.            thread identifiers assigned by GDB, shown in the first column of the 
  2279.            `info threads' display. 
  2280.  
  2281.            If you do not specify `thread threadno' when you set a breakpoint, 
  2282.            the breakpoint applies to all threads of your program. 
  2283.  
  2284.            You can use the thread qualifier on conditional breakpoints as well; 
  2285.            in this case, place `thread threadno' before the breakpoint 
  2286.            condition, like this: 
  2287.  
  2288.                       (gdb) break frik.c:13 thread 28 if bartab > lim
  2289.  
  2290.  Whenever your program stops under GDB for any reason, all threads of execution 
  2291.  stop, not just the current thread.  This allows you to examine the overall 
  2292.  state of the program, including switching between threads, without worrying 
  2293.  that things may change underfoot. 
  2294.  
  2295.  Conversely, whenever you restart the program, all threads start executing. 
  2296.  This is true even when single-stepping with commands like step or next. 
  2297.  
  2298.  In particular, GDB cannot single-step all threads in lockstep. Since thread 
  2299.  scheduling is up to your debugging target's operating system (not controlled 
  2300.  by GDB), other threads may execute more than one statement while the current 
  2301.  thread completes a single step.  Moreover, in general other threads stop in 
  2302.  the middle of a statement, rather than at a clean statement boundary, when the 
  2303.  program stops. 
  2304.  
  2305.  You might even find your program stopped in another thread after continuing or 
  2306.  even single-stepping.  This happens whenever some other thread runs into a 
  2307.  breakpoint, a signal, or an exception before the first thread completes 
  2308.  whatever you requested. 
  2309.  
  2310.  
  2311. ΓòÉΓòÉΓòÉ 9. Examining the Stack ΓòÉΓòÉΓòÉ
  2312.  
  2313. When your program has stopped, the first thing you need to know is where it 
  2314. stopped and how it got there. 
  2315.  
  2316. Each time your program performs a function call, information about the call is 
  2317. generated. That information includes the location of the call in your program, 
  2318. the arguments of the call, and the local variables of the function being 
  2319. called. The information is saved in a block of data called a stack frame. The 
  2320. stack frames are allocated in a region of memory called the call stack. 
  2321.  
  2322. When your program stops, the GDB commands for examining the stack allow you to 
  2323. see all of this information. 
  2324.  
  2325. One of the stack frames is selected by GDB and many GDB commands refer 
  2326. implicitly to the selected frame.  In particular, whenever you ask GDB for the 
  2327. value of a variable in your program, the value is found in the selected frame. 
  2328. There are special GDB commands to select whichever frame you are interested in. 
  2329. See Selecting a frame. 
  2330.  
  2331. When your program stops, GDB automatically selects the currently executing 
  2332. frame and describes it briefly, similar to the frame command (see Information 
  2333. about a frame). 
  2334.  
  2335.  Frames                                  Stack frames 
  2336.  Backtrace                               Backtraces 
  2337.  Selection                               Selecting a frame 
  2338.  Frame Info                              Information on a frame 
  2339.  
  2340.  MIPS Stack                              MIPS machines and the function stack 
  2341.  
  2342.  
  2343. ΓòÉΓòÉΓòÉ 9.1. Stack frames ΓòÉΓòÉΓòÉ
  2344.  
  2345. The call stack is divided up into contiguous pieces called stack frames, or 
  2346. frames for short; each frame is the data associated with one call to one 
  2347. function.  The frame contains the arguments given to the function, the 
  2348. function's local variables, and the address at which the function is executing. 
  2349.  
  2350. When your program is started, the stack has only one frame, that of the 
  2351. function main.  This is called the initial frame or the outermost frame.  Each 
  2352. time a function is called, a new frame is made.  Each time a function returns, 
  2353. the frame for that function invocation is eliminated.  If a function is 
  2354. recursive, there can be many frames for the same function.  The frame for the 
  2355. function in which execution is actually occurring is called the innermost 
  2356. frame.  This is the most recently created of all the stack frames that still 
  2357. exist. 
  2358.  
  2359. Inside your program, stack frames are identified by their addresses.  A stack 
  2360. frame consists of many bytes, each of which has its own address; each kind of 
  2361. computer has a convention for choosing one byte whose address serves as the 
  2362. address of the frame.  Usually this address is kept in a register called the 
  2363. frame pointer register while execution is going on in that frame. 
  2364.  
  2365. GDB assigns numbers to all existing stack frames, starting with zero for the 
  2366. innermost frame, one for the frame that called it, and so on upward.  These 
  2367. numbers do not really exist in your program; they are assigned by GDB to give 
  2368. you a way of designating stack frames in GDB commands. 
  2369.  
  2370. Some compilers provide a way to compile functions so that they operate without 
  2371. stack frames.  (For example, the gcc option `-fomit-frame-pointer' generates 
  2372. functions without a frame.) This is occasionally done with heavily used library 
  2373. functions to save the frame setup time.  GDB has limited facilities for dealing 
  2374. with these function invocations.  If the innermost function invocation has no 
  2375. stack frame, GDB nevertheless regards it as though it had a separate frame, 
  2376. which is numbered zero as usual, allowing correct tracing of the function call 
  2377. chain.  However, GDB has no provision for frameless functions elsewhere in the 
  2378. stack. 
  2379.  
  2380.  frame args 
  2381.            The frame command allows you to move from one stack frame to 
  2382.            another, and to print the stack frame you select.  args may be 
  2383.            either the address of the frame of the stack frame number.  Without 
  2384.            an argument, frame prints the current stack frame. 
  2385.  
  2386.  select-frame 
  2387.            The select-frame command allows you to move from one stack frame to 
  2388.            another without printing the frame.  This is the silent version of 
  2389.            frame. 
  2390.  
  2391.  
  2392. ΓòÉΓòÉΓòÉ 9.2. Backtraces ΓòÉΓòÉΓòÉ
  2393.  
  2394. A backtrace is a summary of how your program got where it is.  It shows one 
  2395. line per frame, for many frames, starting with the currently executing frame 
  2396. (frame zero), followed by its caller (frame one), and on up the stack. 
  2397.  
  2398.  backtrace 
  2399.  bt 
  2400.            Print a backtrace of the entire stack: one line per frame for all 
  2401.            frames in the stack. 
  2402.  
  2403.            You can stop the backtrace at any time by typing the system 
  2404.            interrupt character, normally C-c. 
  2405.  
  2406.  backtrace n 
  2407.  bt n 
  2408.            Similar, but print only the innermost n frames. 
  2409.  
  2410.  backtrace -n 
  2411.  bt -n 
  2412.            Similar, but print only the outermost n frames. 
  2413.  
  2414.  The names where and info stack (abbreviated info s) are additional aliases for 
  2415.  backtrace. 
  2416.  
  2417.  Each line in the backtrace shows the frame number and the function name. The 
  2418.  program counter value is also shown---unless you use set print address off. 
  2419.  The backtrace also shows the source file name and line number, as well as the 
  2420.  arguments to the function.  The program counter value is omitted if it is at 
  2421.  the beginning of the code for that line number. 
  2422.  
  2423.  Here is an example of a backtrace.  It was made with the command `bt 3', so it 
  2424.  shows the innermost three frames. 
  2425.  
  2426.   #0  m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
  2427.       at builtin.c:993
  2428.   #1  0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
  2429.   #2  0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
  2430.       at macro.c:71
  2431.   (More stack frames follow...)
  2432.  
  2433.  The display for frame zero does not begin with a program counter value, 
  2434.  indicating that your program has stopped at the beginning of the code for line 
  2435.  993 of builtin.c. 
  2436.  
  2437.  
  2438. ΓòÉΓòÉΓòÉ 9.3. Selecting a frame ΓòÉΓòÉΓòÉ
  2439.  
  2440. Most commands for examining the stack and other data in your program work on 
  2441. whichever stack frame is selected at the moment.  Here are the commands for 
  2442. selecting a stack frame; all of them finish by printing a brief description of 
  2443. the stack frame just selected. 
  2444.  
  2445.  frame n 
  2446.  f n 
  2447.            Select frame number n.  Recall that frame zero is the innermost 
  2448.            (currently executing) frame, frame one is the frame that called the 
  2449.            innermost one, and so on.  The highest-numbered frame is the one for 
  2450.            main. 
  2451.  
  2452.  frame addr 
  2453.  f addr 
  2454.            Select the frame at address addr.  This is useful mainly if the 
  2455.            chaining of stack frames has been damaged by a bug, making it 
  2456.            impossible for GDB to assign numbers properly to all frames.  In 
  2457.            addition, this can be useful when your program has multiple stacks 
  2458.            and switches between them. 
  2459.  
  2460.            On the SPARC architecture, frame needs two addresses to select an 
  2461.            arbitrary frame: a frame pointer and a stack pointer. 
  2462.  
  2463.            On the MIPS and Alpha architecture, it needs two addresses: a stack 
  2464.            pointer and a program counter. 
  2465.  
  2466.            On the 29k architecture, it needs three addresses: a register stack 
  2467.            pointer, a program counter, and a memory stack pointer. 
  2468.  
  2469.  up n 
  2470.            Move n frames up the stack.  For positive numbers n, this advances 
  2471.            toward the outermost frame, to higher frame numbers, to frames that 
  2472.            have existed longer.  n defaults to one. 
  2473.  
  2474.  down n 
  2475.            Move n frames down the stack.  For positive numbers n, this advances 
  2476.            toward the innermost frame, to lower frame numbers, to frames that 
  2477.            were created more recently.  n defaults to one.  You may abbreviate 
  2478.            down as do. 
  2479.  
  2480.  All of these commands end by printing two lines of output describing the 
  2481.  frame.  The first line shows the frame number, the function name, the 
  2482.  arguments, and the source file and line number of execution in that frame. 
  2483.  The second line shows the text of that source line. 
  2484.  
  2485.  For example: 
  2486.  
  2487.   (gdb) up
  2488.   #1  0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
  2489.       at env.c:10
  2490.   10              read_input_file (argv[i]);
  2491.  
  2492.  After such a printout, the list command with no arguments prints ten lines 
  2493.  centered on the point of execution in the frame. See Printing source lines. 
  2494.  
  2495.  up-silently n 
  2496.  down-silently n 
  2497.            These two commands are variants of up and down, respectively; they 
  2498.            differ in that they do their work silently, without causing display 
  2499.            of the new frame.  They are intended primarily for use in GDB 
  2500.            command scripts, where the output might be unnecessary and 
  2501.            distracting. 
  2502.  
  2503.  
  2504. ΓòÉΓòÉΓòÉ 9.4. Information about a frame ΓòÉΓòÉΓòÉ
  2505.  
  2506. There are several other commands to print information about the selected stack 
  2507. frame. 
  2508.  
  2509.  frame 
  2510.  f 
  2511.            When used without any argument, this command does not change which 
  2512.            frame is selected, but prints a brief description of the currently 
  2513.            selected stack frame.  It can be abbreviated f.  With an argument, 
  2514.            this command is used to select a stack frame. See Selecting a frame. 
  2515.  
  2516.  info frame 
  2517.  info f 
  2518.            This command prints a verbose description of the selected stack 
  2519.            frame, including: 
  2520.  
  2521.                the address of the frame 
  2522.  
  2523.                the address of the next frame down (called by this frame) 
  2524.  
  2525.                the address of the next frame up (caller of this frame) 
  2526.  
  2527.                the language in which the source code corresponding to this 
  2528.                 frame is written 
  2529.  
  2530.                the address of the frame's arguments 
  2531.  
  2532.                the program counter saved in it (the address of execution in 
  2533.                 the caller frame) 
  2534.  
  2535.                which registers were saved in the frame 
  2536.  
  2537.            The verbose description is useful when something has gone wrong that 
  2538.            has made the stack format fail to fit the usual conventions. 
  2539.  
  2540.  info frame addr 
  2541.  info f addr 
  2542.            Print a verbose description of the frame at address addr, without 
  2543.            selecting that frame.  The selected frame remains unchanged by this 
  2544.            command.  This requires the same kind of address (more than one for 
  2545.            some architectures) that you specify in the frame command. See 
  2546.            Selecting a frame. 
  2547.  
  2548.  info args 
  2549.            Print the arguments of the selected frame, each on a separate line. 
  2550.  
  2551.  info locals 
  2552.            Print the local variables of the selected frame, each on a separate 
  2553.            line.  These are all variables (declared either static or automatic) 
  2554.            accessible at the point of execution of the selected frame. 
  2555.  
  2556.  info catch 
  2557.            Print a list of all the exception handlers that are active in the 
  2558.            current stack frame at the current point of execution.  To see other 
  2559.            exception handlers, visit the associated frame (using the up, down, 
  2560.            or frame commands); then type info catch. See Breakpoints and 
  2561.            exceptions. 
  2562.  
  2563.  
  2564. ΓòÉΓòÉΓòÉ 9.5. MIPS machines and the function stack ΓòÉΓòÉΓòÉ
  2565.  
  2566. MIPS based computers use an unusual stack frame, which sometimes requires GDB 
  2567. to search backward in the object code to find the beginning of a function. 
  2568.  
  2569. To improve response time (especially for embedded applications, where GDB may 
  2570. be restricted to a slow serial line for this search) you may want to limit the 
  2571. size of this search, using one of these commands: 
  2572.  
  2573.  set heuristic-fence-post limit 
  2574.            Restrict GDB to examining at most limit bytes in its search for the 
  2575.            beginning of a function.  A value of 0 (the default) means there is 
  2576.            no limit.  However, except for 0, the larger the limit the more 
  2577.            bytes heuristic-fence-post must search and therefore the longer it 
  2578.            takes to run. 
  2579.  
  2580.  show heuristic-fence-post 
  2581.            Display the current limit. 
  2582.  
  2583.  These commands are available only when GDB is configured for debugging 
  2584.  programs on MIPS processors. 
  2585.  
  2586.  
  2587. ΓòÉΓòÉΓòÉ 10. Examining Source Files ΓòÉΓòÉΓòÉ
  2588.  
  2589. GDB can print parts of your program's source, since the debugging information 
  2590. recorded in the program tells GDB what source files were used to build it. 
  2591. When your program stops, GDB spontaneously prints the line where it stopped. 
  2592. Likewise, when you select a stack frame (see Selecting a frame), GDB prints the 
  2593. line where execution in that frame has stopped.  You can print other portions 
  2594. of source files by explicit command. 
  2595.  
  2596. If you use GDB through its gnu Emacs interface, you may prefer to use Emacs 
  2597. facilities to view source; see Using GDB under gnu Emacs. 
  2598.  
  2599.  List                                    Printing source lines 
  2600.  
  2601.  Search                                  Searching source files 
  2602.  
  2603.  Source Path                             Specifying source directories 
  2604.  Machine Code                            Source and machine code 
  2605.  
  2606.  
  2607. ΓòÉΓòÉΓòÉ 10.1. Printing source lines ΓòÉΓòÉΓòÉ
  2608.  
  2609. To print lines from a source file, use the list command (abbreviated l).  By 
  2610. default, ten lines are printed. There are several ways to specify what part of 
  2611. the file you want to print. 
  2612.  
  2613. Here are the forms of the list command most commonly used: 
  2614.  
  2615.  list linenum 
  2616.            Print lines centered around line number linenum in the current 
  2617.            source file. 
  2618.  
  2619.  list function 
  2620.            Print lines centered around the beginning of function function. 
  2621.  
  2622.  list 
  2623.            Print more lines.  If the last lines printed were printed with a 
  2624.            list command, this prints lines following the last lines printed; 
  2625.            however, if the last line printed was a solitary line printed as 
  2626.            part of displaying a stack frame ( see Examining the Stack), this 
  2627.            prints lines centered around that line. 
  2628.  
  2629.  list - 
  2630.            Print lines just before the lines last printed. 
  2631.  
  2632.  By default, GDB prints ten source lines with any of these forms of the list 
  2633.  command.  You can change this using set listsize: 
  2634.  
  2635.  set listsize count 
  2636.            Make the list command display count source lines (unless the list 
  2637.            argument explicitly specifies some other number). 
  2638.  
  2639.  show listsize 
  2640.            Display the number of lines that list prints. 
  2641.  
  2642.  Repeating a list command with RET discards the argument, so it is equivalent 
  2643.  to typing just list.  This is more useful than listing the same lines again. 
  2644.  An exception is made for an argument of `-'; that argument is preserved in 
  2645.  repetition so that each repetition moves up in the source file. 
  2646.  
  2647.  In general, the list command expects you to supply zero, one or two linespecs. 
  2648.  Linespecs specify source lines; there are several ways of writing them but the 
  2649.  effect is always to specify some source line. Here is a complete description 
  2650.  of the possible arguments for list: 
  2651.  
  2652.  list linespec 
  2653.            Print lines centered around the line specified by linespec. 
  2654.  
  2655.  list first,last 
  2656.            Print lines from first to last.  Both arguments are linespecs. 
  2657.  
  2658.  list ,last 
  2659.            Print lines ending with last. 
  2660.  
  2661.  list first, 
  2662.            Print lines starting with first. 
  2663.  
  2664.  list + 
  2665.            Print lines just after the lines last printed. 
  2666.  
  2667.  list - 
  2668.            Print lines just before the lines last printed. 
  2669.  
  2670.  list 
  2671.            As described in the preceding table. 
  2672.  
  2673.  Here are the ways of specifying a single source line---all the kinds of 
  2674.  linespec. 
  2675.  
  2676.  number 
  2677.            Specifies line number of the current source file. When a list 
  2678.            command has two linespecs, this refers to the same source file as 
  2679.            the first linespec. 
  2680.  
  2681.  +offset 
  2682.            Specifies the line offset lines after the last line printed. When 
  2683.            used as the second linespec in a list command that has two, this 
  2684.            specifies the line offset lines down from the first linespec. 
  2685.  
  2686.  -offset 
  2687.            Specifies the line offset lines before the last line printed. 
  2688.  
  2689.  filename:number 
  2690.            Specifies line number in the source file filename. 
  2691.  
  2692.  function 
  2693.            Specifies the line that begins the body of the function function. 
  2694.            For example: in C, this is the line with the open brace. 
  2695.  
  2696.  filename:function 
  2697.            Specifies the line of the open-brace that begins the body of the 
  2698.            function function in the file filename.  You only need the file name 
  2699.            with a function name to avoid ambiguity when there are identically 
  2700.            named functions in different source files. 
  2701.  
  2702.  *address 
  2703.            Specifies the line containing the program address address. address 
  2704.            may be any expression. 
  2705.  
  2706.  
  2707. ΓòÉΓòÉΓòÉ 10.2. Searching source files ΓòÉΓòÉΓòÉ
  2708.  
  2709. There are two commands for searching through the current source file for a 
  2710. regular expression. 
  2711.  
  2712.  forward-search regexp 
  2713.  search regexp 
  2714.            The command `forward-search regexp' checks each line, starting with 
  2715.            the one following the last line listed, for a match for regexp.  It 
  2716.            lists the line that is found.  You can use the synonym `search 
  2717.            regexp' or abbreviate the command name as fo. 
  2718.  
  2719.  reverse-search regexp 
  2720.            The command `reverse-search regexp' checks each line, starting with 
  2721.            the one before the last line listed and going backward, for a match 
  2722.            for regexp.  It lists the line that is found.  You can abbreviate 
  2723.            this command as rev. 
  2724.  
  2725.  
  2726. ΓòÉΓòÉΓòÉ 10.3. Specifying source directories ΓòÉΓòÉΓòÉ
  2727.  
  2728. Executable programs sometimes do not record the directories of the source files 
  2729. from which they were compiled, just the names.  Even when they do, the 
  2730. directories could be moved between the compilation and your debugging session. 
  2731. GDB has a list of directories to search for source files; this is called the 
  2732. source path.  Each time GDB wants a source file, it tries all the directories 
  2733. in the list, in the order they are present in the list, until it finds a file 
  2734. with the desired name.  Note that the executable search path is not used for 
  2735. this purpose.  Neither is the current working directory, unless it happens to 
  2736. be in the source path. 
  2737.  
  2738. If GDB cannot find a source file in the source path, and the object program 
  2739. records a directory, GDB tries that directory too.  If the source path is 
  2740. empty, and there is no record of the compilation directory, GDB looks in the 
  2741. current directory as a last resort. 
  2742.  
  2743. Whenever you reset or rearrange the source path, GDB clears out any information 
  2744. it has cached about where source files are found and where each line is in the 
  2745. file. 
  2746.  
  2747. When you start GDB, its source path is empty. To add other directories, use the 
  2748. directory command. 
  2749.  
  2750.  directory dirname ... 
  2751.  
  2752.  dir dirname ... 
  2753.            Add directory dirname to the front of the source path.  Several 
  2754.            directory names may be given to this command, separated by `:' or 
  2755.            whitespace.  You may specify a directory that is already in the 
  2756.            source path; this moves it forward, so GDB searches it sooner. 
  2757.  
  2758.            You can use the string `$cdir' to refer to the compilation directory 
  2759.            (if one is recorded), and `$cwd' to refer to the current working 
  2760.            directory.  `$cwd' is not the same as `.'---the former tracks the 
  2761.            current working directory as it changes during your GDB session, 
  2762.            while the latter is immediately expanded to the current directory at 
  2763.            the time you add an entry to the source path. 
  2764.  
  2765.  directory 
  2766.            Reset the source path to empty again.  This requires confirmation. 
  2767.  
  2768.  show directories 
  2769.            Print the source path: show which directories it contains. 
  2770.  
  2771.  If your source path is cluttered with directories that are no longer of 
  2772.  interest, GDB may sometimes cause confusion by finding the wrong versions of 
  2773.  source.  You can correct the situation as follows: 
  2774.  
  2775.    1. Use directory with no argument to reset the source path to empty. 
  2776.  
  2777.    2. Use directory with suitable arguments to reinstall the directories you 
  2778.       want in the source path.  You can add all the directories in one command. 
  2779.  
  2780.  
  2781. ΓòÉΓòÉΓòÉ 10.4. Source and machine code ΓòÉΓòÉΓòÉ
  2782.  
  2783. You can use the command info line to map source lines to program addresses (and 
  2784. vice versa), and the command disassemble to display a range of addresses as 
  2785. machine instructions.  When run under gnu Emacs mode, the info line command now 
  2786. causes the arrow to point to the line specified.  Also, info line prints 
  2787. addresses in symbolic form as well as hex. 
  2788.  
  2789.  info line linespec 
  2790.            Print the starting and ending addresses of the compiled code for 
  2791.            source line linespec.  You can specify source lines in any of the 
  2792.            ways understood by the list command ( see Printing source lines). 
  2793.  
  2794.  For example, we can use info line to discover the location of the object code 
  2795.  for the first line of function m4_changequote: 
  2796.  
  2797.   (gdb) info line m4_changecom
  2798.   Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
  2799.  
  2800.  We can also inquire (using *addr as the form for linespec) what source line 
  2801.  covers a particular address: 
  2802.  
  2803.   (gdb) info line *0x63ff
  2804.   Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
  2805.  
  2806.  After info line, the default address for the x command is changed to the 
  2807.  starting address of the line, so that `x/i' is sufficient to begin examining 
  2808.  the machine code ( see Examining memory).  Also, this address is saved as the 
  2809.  value of the convenience variable $_ ( see Convenience variables). 
  2810.  
  2811.  disassemble 
  2812.            This specialized command dumps a range of memory as machine 
  2813.            instructions.  The default memory range is the function surrounding 
  2814.            the program counter of the selected frame.  A single argument to 
  2815.            this command is a program counter value; GDB dumps the function 
  2816.            surrounding this value.  Two arguments specify a range of addresses 
  2817.            (first inclusive, second exclusive) to dump. 
  2818.  
  2819.  We can use disassemble to inspect the object code range shown in the last info 
  2820.  line example (the example shows SPARC machine instructions): 
  2821.  
  2822.   (gdb) disas 0x63e4 0x6404
  2823.   Dump of assembler code from 0x63e4 to 0x6404:
  2824.   0x63e4 <builtin_init+5340>:     ble 0x63f8 <builtin_init+5360>
  2825.   0x63e8 <builtin_init+5344>:     sethi %hi(0x4c00), %o0
  2826.   0x63ec <builtin_init+5348>:     ld [%i1+4], %o0
  2827.   0x63f0 <builtin_init+5352>:     b 0x63fc <builtin_init+5364>
  2828.   0x63f4 <builtin_init+5356>:     ld [%o0+4], %o0
  2829.   0x63f8 <builtin_init+5360>:     or %o0, 0x1a4, %o0
  2830.   0x63fc <builtin_init+5364>:     call 0x9288 <path_search>
  2831.   0x6400 <builtin_init+5368>:     nop
  2832.   End of assembler dump.
  2833.  
  2834.  
  2835. ΓòÉΓòÉΓòÉ 11. Examining Data ΓòÉΓòÉΓòÉ
  2836.  
  2837. The usual way to examine data in your program is with the print command 
  2838. (abbreviated p), or its synonym inspect. It evaluates and prints the value of 
  2839. an expression of the language your program is written in ( see Using GDB with 
  2840. Different Languages). 
  2841.  
  2842.  print exp 
  2843.  print /f exp 
  2844.            exp is an expression (in the source language).  By default the value 
  2845.            of exp is printed in a format appropriate to its data type; you can 
  2846.            choose a different format by specifying `/f', where f is a letter 
  2847.            specifying the format; see Output formats. 
  2848.  
  2849.  print 
  2850.  print /f 
  2851.            If you omit exp, GDB displays the last value again (from the value 
  2852.            history; see Value history).  This allows you to conveniently 
  2853.            inspect the same value in an alternative format. 
  2854.  
  2855.  A more low-level way of examining data is with the x command. It examines data 
  2856.  in memory at a specified address and prints it in a specified format.  See 
  2857.  Examining memory. 
  2858.  
  2859.  If you are interested in information about types, or about how the fields of a 
  2860.  struct or class are declared, use the ptype exp command rather than print. See 
  2861.  Examining the Symbol Table. 
  2862.  
  2863.  Expressions                             Expressions 
  2864.  Variables                               Program variables 
  2865.  Arrays                                  Artificial arrays 
  2866.  Output Formats                          Output formats 
  2867.  Memory                                  Examining memory 
  2868.  Auto Display                            Automatic display 
  2869.  Print Settings                          Print settings 
  2870.  Value History                           Value history 
  2871.  Convenience Vars                        Convenience variables 
  2872.  Registers                               Registers 
  2873.  
  2874.  Floating Point Hardware                 Floating point hardware 
  2875.  
  2876.  
  2877. ΓòÉΓòÉΓòÉ 11.1. Expressions ΓòÉΓòÉΓòÉ
  2878.  
  2879. print and many other GDB commands accept an expression and compute its value. 
  2880. Any kind of constant, variable or operator defined by the programming language 
  2881. you are using is valid in an expression in GDB.  This includes conditional 
  2882. expressions, function calls, casts and string constants.  It unfortunately does 
  2883. not include symbols defined by preprocessor #define commands. 
  2884.  
  2885. GDB now supports array constants in expressions input by the user.  The syntax 
  2886. is {element, element...}.  For example, you can now use the command print {1, 
  2887. 2, 3} to build up an array in memory that is malloc'd in the target program. 
  2888.  
  2889. Because C is so widespread, most of the expressions shown in examples in this 
  2890. manual are in C. See Using GDB with Different Languages, for information on how 
  2891. to use expressions in other languages. 
  2892.  
  2893. In this section, we discuss operators that you can use in GDB expressions 
  2894. regardless of your programming language. 
  2895.  
  2896. Casts are supported in all languages, not just in C, because it is so useful to 
  2897. cast a number into a pointer in order to examine a structure at that address in 
  2898. memory. 
  2899.  
  2900. GDB supports these operators, in addition to those common to programming 
  2901. languages: 
  2902.  
  2903.  @ 
  2904.            `@' is a binary operator for treating parts of memory as arrays. See 
  2905.            Artificial arrays, for more information. 
  2906.  
  2907.  :: 
  2908.            `::' allows you to specify a variable in terms of the file or 
  2909.            function where it is defined.  See Program variables. 
  2910.  
  2911.  {type} addr 
  2912.            Refers to an object of type type stored at address addr in memory. 
  2913.            addr may be any expression whose value is an integer or pointer (but 
  2914.            parentheses are required around binary operators, just as in a 
  2915.            cast).  This construct is allowed regardless of what kind of data is 
  2916.            normally supposed to reside at addr. 
  2917.  
  2918.  
  2919. ΓòÉΓòÉΓòÉ 11.2. Program variables ΓòÉΓòÉΓòÉ
  2920.  
  2921. The most common kind of expression to use is the name of a variable in your 
  2922. program. 
  2923.  
  2924. Variables in expressions are understood in the selected stack frame (see 
  2925. Selecting a frame); they must be either: 
  2926.  
  2927.      global (or static) 
  2928.  
  2929.  or 
  2930.  
  2931.      visible according to the scope rules of the programming language from the 
  2932.       point of execution in that frame 
  2933.  
  2934.  This means that in the function 
  2935.  
  2936.   foo (a)
  2937.        int a;
  2938.   {
  2939.     bar (a);
  2940.     {
  2941.       int b = test ();
  2942.       bar (b);
  2943.     }
  2944.   }
  2945.  
  2946.  you can examine and use the variable a whenever your program is executing 
  2947.  within the function foo, but you can only use or examine the variable b while 
  2948.  your program is executing inside the block where b is declared. 
  2949.  
  2950.  There is an exception: you can refer to a variable or function whose scope is 
  2951.  a single source file even if the current execution point is not in this file. 
  2952.  But it is possible to have more than one such variable or function with the 
  2953.  same name (in different source files).  If that happens, referring to that 
  2954.  name has unpredictable effects.  If you wish, you can specify a static 
  2955.  variable in a particular function or file, using the colon-colon notation: 
  2956.  
  2957.   file::variable
  2958.   function::variable
  2959.  
  2960.  Here file or function is the name of the context for the static variable.  In 
  2961.  the case of file names, you can use quotes to make sure GDB parses the file 
  2962.  name as a single word---for example, to print a global value of x defined in 
  2963.  `f2.c': 
  2964.  
  2965.   (gdb) p 'f2.c'::x
  2966.  
  2967.  This use of `::' is very rarely in conflict with the very similar use of the 
  2968.  same notation in C++.  GDB also supports use of the C++ scope resolution 
  2969.  operator in GDB expressions. 
  2970.  
  2971.  Warning: Occasionally, a local variable may appear to have the wrong value at 
  2972.  certain points in a function---just after entry to a new scope, and just 
  2973.  before exit. You may see this problem when you are stepping by machine 
  2974.  instructions. This is because, on most machines, it takes more than one 
  2975.  instruction to set up a stack frame (including local variable definitions); if 
  2976.  you are stepping by machine instructions, variables may appear to have the 
  2977.  wrong values until the stack frame is completely built.  On exit, it usually 
  2978.  also takes more than one machine instruction to destroy a stack frame; after 
  2979.  you begin stepping through that group of instructions, local variable 
  2980.  definitions may be gone. 
  2981.  
  2982.  
  2983. ΓòÉΓòÉΓòÉ 11.3. Artificial arrays ΓòÉΓòÉΓòÉ
  2984.  
  2985. It is often useful to print out several successive objects of the same type in 
  2986. memory; a section of an array, or an array of dynamically determined size for 
  2987. which only a pointer exists in the program. 
  2988.  
  2989. You can do this by referring to a contiguous span of memory as an artificial 
  2990. array, using the binary operator `@'.  The left operand of `@' should be the 
  2991. first element of the desired array and be an individual object.  The right 
  2992. operand should be the desired length of the array.  The result is an array 
  2993. value whose elements are all of the type of the left argument.  The first 
  2994. element is actually the left argument; the second element comes from bytes of 
  2995. memory immediately following those that hold the first element, and so on. 
  2996. Here is an example.  If a program says 
  2997.  
  2998. int *array = (int *) malloc (len * sizeof (int));
  2999.  
  3000. you can print the contents of array with 
  3001.  
  3002. p *array@len
  3003.  
  3004. The left operand of `@' must reside in memory.  Array values made with `@' in 
  3005. this way behave just like other arrays in terms of subscripting, and are 
  3006. coerced to pointers when used in expressions. Artificial arrays most often 
  3007. appear in expressions via the value history (see Value history), after printing 
  3008. one out. 
  3009.  
  3010. Another way to create an artificial array is to use a cast. This re-interprets 
  3011. a value as if it were an array. The value need not be in memory: 
  3012.  
  3013. (gdb) p/x (short[2])0x12345678
  3014. $1 = {0x1234, 0x5678}
  3015.  
  3016. As a convenience, if you leave the array length out (as in `(type)[])value') 
  3017. gdb calculates the size to fill the value (as `sizeof(value)/sizeof(type)': 
  3018.  
  3019. (gdb) p/x (short[])0x12345678
  3020. $2 = {0x1234, 0x5678}
  3021.  
  3022. Sometimes the artificial array mechanism is not quite enough; in moderately 
  3023. complex data structures, the elements of interest may not actually be 
  3024. adjacent---for example, if you are interested in the values of pointers in an 
  3025. array.  One useful work-around in this situation is to use a convenience 
  3026. variable ( see Convenience variables) as a counter in an expression that prints 
  3027. the first interesting value, and then repeat that expression via RET.  For 
  3028. instance, suppose you have an array dtab of pointers to structures, and you are 
  3029. interested in the values of a field fv in each structure.  Here is an example 
  3030. of what you might type: 
  3031.  
  3032. set $i = 0
  3033. p dtab[$i++]->fv
  3034. RET
  3035. RET
  3036. ...
  3037.  
  3038.  
  3039. ΓòÉΓòÉΓòÉ 11.4. Output formats ΓòÉΓòÉΓòÉ
  3040.  
  3041. By default, GDB prints a value according to its data type.  Sometimes this is 
  3042. not what you want.  For example, you might want to print a number in hex, or a 
  3043. pointer in decimal.  Or you might want to view data in memory at a certain 
  3044. address as a character string or as an instruction.  To do these things, 
  3045. specify an output format when you print a value. 
  3046.  
  3047. The simplest use of output formats is to say how to print a value already 
  3048. computed.  This is done by starting the arguments of the print command with a 
  3049. slash and a format letter.  The format letters supported are: 
  3050.  
  3051.  x 
  3052.            Regard the bits of the value as an integer, and print the integer in 
  3053.            hexadecimal. 
  3054.  
  3055.  d 
  3056.            Print as integer in signed decimal. 
  3057.  
  3058.  u 
  3059.            Print as integer in unsigned decimal. 
  3060.  
  3061.  o 
  3062.            Print as integer in octal. 
  3063.  
  3064.  t 
  3065.            Print as integer in binary.  The letter `t' stands for ``two''. (1) 
  3066.  
  3067.  a 
  3068.            Print as an address, both absolute in hexadecimal and as an offset 
  3069.            from the nearest preceding symbol.  You can use this format used to 
  3070.            discover where (in what function) an unknown address is located: 
  3071.  
  3072.                       (gdb) p/a 0x54320
  3073.                       $3 = 0x54320 <_initialize_vx+396>
  3074.  
  3075.  c 
  3076.            Regard as an integer and print it as a character constant. 
  3077.  
  3078.  f 
  3079.            Regard the bits of the value as a floating point number and print 
  3080.            using typical floating point syntax. 
  3081.  
  3082.  For example, to print the program counter in hex (see Registers), type 
  3083.  
  3084.   p/x $pc
  3085.  
  3086.  Note that no space is required before the slash; this is because command names 
  3087.  in GDB cannot contain a slash. 
  3088.  
  3089.  To reprint the last value in the value history with a different format, you 
  3090.  can use the print command with just a format and no expression.  For example, 
  3091.  `p/x' reprints the last value in hex. 
  3092.  
  3093.  
  3094. ΓòÉΓòÉΓòÉ 11.5. Examining memory ΓòÉΓòÉΓòÉ
  3095.  
  3096. You can use the command x (for ``examine'') to examine memory in any of several 
  3097. formats, independently of your program's data types. 
  3098.  
  3099.  x/nfu addr 
  3100.  x addr 
  3101.  x 
  3102.            Use the x command to examine memory. 
  3103.  
  3104.  n, f, and u are all optional parameters that specify how much memory to 
  3105.  display and how to format it; addr is an expression giving the address where 
  3106.  you want to start displaying memory. If you use defaults for nfu, you need not 
  3107.  type the slash `/'. Several commands set convenient defaults for addr. 
  3108.  
  3109.  n, the repeat count 
  3110.            The repeat count is a decimal integer; the default is 1.  It 
  3111.            specifies how much memory (counting by units u) to display. 
  3112.  
  3113.  f, the display format 
  3114.            The display format is one of the formats used by print, `s' 
  3115.            (null-terminated string), or `i' (machine instruction). The default 
  3116.            is `x' (hexadecimal) initially. The default changes each time you 
  3117.            use either x or print. 
  3118.  
  3119.  u, the unit size 
  3120.            The unit size is any of 
  3121.  
  3122.            b 
  3123.                           Bytes. 
  3124.  
  3125.            h 
  3126.                           Halfwords (two bytes). 
  3127.  
  3128.            w 
  3129.                           Words (four bytes).  This is the initial default. 
  3130.  
  3131.            g 
  3132.                           Giant words (eight bytes). 
  3133.  
  3134.            Each time you specify a unit size with x, that size becomes the 
  3135.            default unit the next time you use x.  (For the `s' and `i' formats, 
  3136.            the unit size is ignored and is normally not written.) 
  3137.  
  3138.  addr, starting display address 
  3139.            addr is the address where you want GDB to begin displaying memory. 
  3140.            The expression need not have a pointer value (though it may); it is 
  3141.            always interpreted as an integer address of a byte of memory. See 
  3142.            Expressions, for more information on expressions.  The default for 
  3143.            addr is usually just after the last address examined---but several 
  3144.            other commands also set the default address: info breakpoints (to 
  3145.            the address of the last breakpoint listed), info line (to the 
  3146.            starting address of a line), and print (if you use it to display a 
  3147.            value from memory). 
  3148.  
  3149.  For example, `x/3uh 0x54320' is a request to display three halfwords (h) of 
  3150.  memory, formatted as unsigned decimal integers (`u'), starting at address 
  3151.  0x54320.  `x/4xw $sp' prints the four words (`w') of memory above the stack 
  3152.  pointer (here, `$sp'; see Registers) in hexadecimal (`x'). 
  3153.  
  3154.  Since the letters indicating unit sizes are all distinct from the letters 
  3155.  specifying output formats, you do not have to remember whether unit size or 
  3156.  format comes first; either order works.  The output specifications `4xw' and 
  3157.  `4wx' mean exactly the same thing. (However, the count n must come first; 
  3158.  `wx4' does not work.) 
  3159.  
  3160.  Even though the unit size u is ignored for the formats `s' and `i', you might 
  3161.  still want to use a count n; for example, `3i' specifies that you want to see 
  3162.  three machine instructions, including any operands.  The command disassemble 
  3163.  gives an alternative way of inspecting machine instructions; see Source and 
  3164.  machine code. 
  3165.  
  3166.  All the defaults for the arguments to x are designed to make it easy to 
  3167.  continue scanning memory with minimal specifications each time you use x.  For 
  3168.  example, after you have inspected three machine instructions with `x/3i addr', 
  3169.  you can inspect the next seven with just `x/7'.  If you use RET to repeat the 
  3170.  x command, the repeat count n is used again; the other arguments default as 
  3171.  for successive uses of x. 
  3172.  
  3173.  The addresses and contents printed by the x command are not saved in the value 
  3174.  history because there is often too much of them and they would get in the way. 
  3175.  Instead, GDB makes these values available for subsequent use in expressions as 
  3176.  values of the convenience variables $_ and $__.  After an x command, the last 
  3177.  address examined is available for use in expressions in the convenience 
  3178.  variable $_.  The contents of that address, as examined, are available in the 
  3179.  convenience variable $__. 
  3180.  
  3181.  If the x command has a repeat count, the address and contents saved are from 
  3182.  the last memory unit printed; this is not the same as the last address printed 
  3183.  if several units were printed on the last line of output. 
  3184.  
  3185.  
  3186. ΓòÉΓòÉΓòÉ 11.6. Automatic display ΓòÉΓòÉΓòÉ
  3187.  
  3188. If you find that you want to print the value of an expression frequently (to 
  3189. see how it changes), you might want to add it to the automatic display list so 
  3190. that GDB prints its value each time your program stops. Each expression added 
  3191. to the list is given a number to identify it; to remove an expression from the 
  3192. list, you specify that number. The automatic display looks like this: 
  3193.  
  3194. 2: foo = 38
  3195. 3: bar[5] = (struct hack *) 0x3804
  3196.  
  3197. This display shows item numbers, expressions and their current values.  As with 
  3198. displays you request manually using x or print, you can specify the output 
  3199. format you prefer; in fact, display decides whether to use print or x depending 
  3200. on how elaborate your format specification is---it uses x if you specify a unit 
  3201. size, or one of the two formats (`i' and `s') that are only supported by x; 
  3202. otherwise it uses print. 
  3203.  
  3204.  display exp 
  3205.            Add the expression exp to the list of expressions to display each 
  3206.            time your program stops.  See Expressions. 
  3207.  
  3208.            display does not repeat if you press RET again after using it. 
  3209.  
  3210.  display/fmt exp 
  3211.            For fmt specifying only a display format and not a size or count, 
  3212.            add the expression exp to the auto-display list but arrange to 
  3213.            display it each time in the specified format fmt. See Output 
  3214.            formats. 
  3215.  
  3216.  display/fmt addr 
  3217.            For fmt `i' or `s', or including a unit-size or a number of units, 
  3218.            add the expression addr as a memory address to be examined each time 
  3219.            your program stops.  Examining means in effect doing `x/fmt addr'. 
  3220.            See Examining memory. 
  3221.  
  3222.  For example, `display/i $pc' can be helpful, to see the machine instruction 
  3223.  about to be executed each time execution stops (`$pc' is a common name for the 
  3224.  program counter; see Registers). 
  3225.  
  3226.  undisplay dnums... 
  3227.  delete display dnums... 
  3228.            Remove item numbers dnums from the list of expressions to display. 
  3229.  
  3230.            undisplay does not repeat if you press RET after using it. 
  3231.            (Otherwise you would just get the error `No display number ...'.) 
  3232.  
  3233.  disable display dnums... 
  3234.            Disable the display of item numbers dnums.  A disabled display item 
  3235.            is not printed automatically, but is not forgotten.  It may be 
  3236.            enabled again later. 
  3237.  
  3238.  enable display dnums... 
  3239.            Enable display of item numbers dnums.  It becomes effective once 
  3240.            again in auto display of its expression, until you specify 
  3241.            otherwise. 
  3242.  
  3243.  display 
  3244.            Display the current values of the expressions on the list, just as 
  3245.            is done when your program stops. 
  3246.  
  3247.  info display 
  3248.            Print the list of expressions previously set up to display 
  3249.            automatically, each one with its item number, but without showing 
  3250.            the values.  This includes disabled expressions, which are marked as 
  3251.            such. It also includes expressions which would not be displayed 
  3252.            right now because they refer to automatic variables not currently 
  3253.            available. 
  3254.  
  3255.  If a display expression refers to local variables, then it does not make sense 
  3256.  outside the lexical context for which it was set up.  Such an expression is 
  3257.  disabled when execution enters a context where one of its variables is not 
  3258.  defined.  For example, if you give the command display last_char while inside 
  3259.  a function with an argument last_char, GDB displays this argument while your 
  3260.  program continues to stop inside that function.  When it stops 
  3261.  elsewhere---where there is no variable last_char---the display is disabled 
  3262.  automatically.  The next time your program stops where last_char is 
  3263.  meaningful, you can enable the display expression once again. 
  3264.  
  3265.  
  3266. ΓòÉΓòÉΓòÉ 11.7. Print settings ΓòÉΓòÉΓòÉ
  3267.  
  3268. GDB provides the following ways to control how arrays, structures, and symbols 
  3269. are printed. 
  3270.  
  3271. These settings are useful for debugging programs in any language: 
  3272.  
  3273.  set print address 
  3274.  set print address on 
  3275.            GDB prints memory addresses showing the location of stack traces, 
  3276.            structure values, pointer values, breakpoints, and so forth, even 
  3277.            when it also displays the contents of those addresses.  The default 
  3278.            is on.  For example, this is what a stack frame display looks like 
  3279.            with set print address on: 
  3280.  
  3281.                       (gdb) f
  3282.                       #0  set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>")
  3283.                           at input.c:530
  3284.                       530         if (lquote != def_lquote)
  3285.  
  3286.  set print address off 
  3287.            Do not print addresses when displaying their contents.  For example, 
  3288.            this is the same stack frame displayed with set print address off: 
  3289.  
  3290.                       (gdb) set print addr off
  3291.                       (gdb) f
  3292.                       #0  set_quotes (lq="<<", rq=">>") at input.c:530
  3293.                       530         if (lquote != def_lquote)
  3294.  
  3295.            You can use `set print address off' to eliminate all machine 
  3296.            dependent displays from the GDB interface.  For example, with print 
  3297.            address off, you should get the same text for backtraces on all 
  3298.            machines---whether or not they involve pointer arguments. 
  3299.  
  3300.  show print address 
  3301.            Show whether or not addresses are to be printed. 
  3302.  
  3303.  When GDB prints a symbolic address, it normally prints the closest earlier 
  3304.  symbol plus an offset.  If that symbol does not uniquely identify the address 
  3305.  (for example, it is a name whose scope is a single source file), you may need 
  3306.  to clarify.  One way to do this is with info line, for example `info line 
  3307.  *0x4537'.  Alternately, you can set GDB to print the source file and line 
  3308.  number when it prints a symbolic address: 
  3309.  
  3310.  set print symbol-filename on 
  3311.            Tell GDB to print the source file name and line number of a symbol 
  3312.            in the symbolic form of an address. 
  3313.  
  3314.  set print symbol-filename off 
  3315.            Do not print source file name and line number of a symbol.  This is 
  3316.            the default. 
  3317.  
  3318.  show print symbol-filename 
  3319.            Show whether or not GDB will print the source file name and line 
  3320.            number of a symbol in the symbolic form of an address. 
  3321.  
  3322.  Another situation where it is helpful to show symbol filenames and line 
  3323.  numbers is when disassembling code; GDB shows you the line number and source 
  3324.  file that corresponds to each instruction. 
  3325.  
  3326.  Also, you may wish to see the symbolic form only if the address being printed 
  3327.  is reasonably close to the closest earlier symbol: 
  3328.  
  3329.  set print max-symbolic-offset max-offset 
  3330.            Tell GDB to only display the symbolic form of an address if the 
  3331.            offset between the closest earlier symbol and the address is less 
  3332.            than max-offset.  The default is 0, which tells GDB to always print 
  3333.            the symbolic form of an address if any symbol precedes it. 
  3334.  
  3335.  show print max-symbolic-offset 
  3336.            Ask how large the maximum offset is that GDB prints in a symbolic 
  3337.            address. 
  3338.  
  3339.  If you have a pointer and you are not sure where it points, try `set print 
  3340.  symbol-filename on'.  Then you can determine the name and source file location 
  3341.  of the variable where it points, using `p/a pointer'.  This interprets the 
  3342.  address in symbolic form. For example, here GDB shows that a variable ptt 
  3343.  points at another variable t, defined in `hi2.c': 
  3344.  
  3345.   (gdb) set print symbol-filename on
  3346.   (gdb) p/a ptt
  3347.   $4 = 0xe008 <t in hi2.c>
  3348.  
  3349.  Warning: For pointers that point to a local variable, `p/a' does not show the 
  3350.  symbol name and filename of the referent, even with the appropriate set print 
  3351.  options turned on. 
  3352.  
  3353.  Other settings control how different kinds of objects are printed: 
  3354.  
  3355.  set print array 
  3356.  set print array on 
  3357.            Pretty print arrays.  This format is more convenient to read, but 
  3358.            uses more space.  The default is off. 
  3359.  
  3360.  set print array off 
  3361.            Return to compressed format for arrays. 
  3362.  
  3363.  show print array 
  3364.            Show whether compressed or pretty format is selected for displaying 
  3365.            arrays. 
  3366.  
  3367.  set print elements number-of-elements 
  3368.            Set a limit on how many elements of an array GDB will print. If GDB 
  3369.            is printing a large array, it stops printing after it has printed 
  3370.            the number of elements set by the set print elements command. This 
  3371.            limit also applies to the display of strings. Setting 
  3372.            number-of-elements to zero means that the printing is unlimited. 
  3373.  
  3374.  show print elements 
  3375.            Display the number of elements of a large array that GDB will print. 
  3376.            If the number is 0, then the printing is unlimited. 
  3377.  
  3378.  set print null-stop 
  3379.            Cause GDB to stop printing the characters of an array when the first 
  3380.            NULL is encountered.  This is useful when large arrays actually 
  3381.            contain only short strings. 
  3382.  
  3383.  set print pretty on 
  3384.            Cause GDB to print structures in an indented format with one member 
  3385.            per line, like this: 
  3386.  
  3387.                       $1 = {
  3388.                         next = 0x0,
  3389.                         flags = {
  3390.                           sweet = 1,
  3391.                           sour = 1
  3392.                         },
  3393.                         meat = 0x54 "Pork"
  3394.                       }
  3395.  
  3396.  set print pretty off 
  3397.            Cause GDB to print structures in a compact format, like this: 
  3398.  
  3399.                       $1 = {next = 0x0, flags = {sweet = 1, sour = 1}, \
  3400.                       meat = 0x54 "Pork"}
  3401.  
  3402.            This is the default format. 
  3403.  
  3404.  show print pretty 
  3405.            Show which format GDB is using to print structures. 
  3406.  
  3407.  set print sevenbit-strings on 
  3408.            Print using only seven-bit characters; if this option is set, GDB 
  3409.            displays any eight-bit characters (in strings or character values) 
  3410.            using the notation \nnn.  This setting is best if you are working in 
  3411.            English (ascii) and you use the high-order bit of characters as a 
  3412.            marker or ``meta'' bit. 
  3413.  
  3414.  set print sevenbit-strings off 
  3415.            Print full eight-bit characters.  This allows the use of more 
  3416.            international character sets, and is the default. 
  3417.  
  3418.  show print sevenbit-strings 
  3419.            Show whether or not GDB is printing only seven-bit characters. 
  3420.  
  3421.  set print union on 
  3422.            Tell GDB to print unions which are contained in structures.  This is 
  3423.            the default setting. 
  3424.  
  3425.  set print union off 
  3426.            Tell GDB not to print unions which are contained in structures. 
  3427.  
  3428.  show print union 
  3429.            Ask GDB whether or not it will print unions which are contained in 
  3430.            structures. 
  3431.  
  3432.            For example, given the declarations 
  3433.  
  3434.                       typedef enum {Tree, Bug} Species;
  3435.                       typedef enum {Big_tree, Acorn, Seedling} Tree_forms;
  3436.                       typedef enum {Caterpillar, Cocoon, Butterfly}
  3437.                                     Bug_forms;
  3438.  
  3439.                       struct thing {
  3440.                         Species it;
  3441.                         union {
  3442.                           Tree_forms tree;
  3443.                           Bug_forms bug;
  3444.                         } form;
  3445.                       };
  3446.  
  3447.                       struct thing foo = {Tree, {Acorn}};
  3448.  
  3449.            with set print union on in effect `p foo' would print 
  3450.  
  3451.                       $1 = {it = Tree, form = {tree = Acorn, bug = Cocoon}}
  3452.  
  3453.            and with set print union off in effect it would print 
  3454.  
  3455.                       $1 = {it = Tree, form = {...}}
  3456.  
  3457.  These settings are of interest when debugging C++ programs: 
  3458.  
  3459.  set print demangle 
  3460.  set print demangle on 
  3461.            Print C++ names in their source form rather than in the encoded 
  3462.            (``mangled'') form passed to the assembler and linker for type-safe 
  3463.            linkage.  The default is `on'. 
  3464.  
  3465.  show print demangle 
  3466.            Show whether C++ names are printed in mangled or demangled form. 
  3467.  
  3468.  set print asm-demangle 
  3469.  set print asm-demangle on 
  3470.            Print C++ names in their source form rather than their mangled form, 
  3471.            even in assembler code printouts such as instruction disassemblies. 
  3472.            The default is off. 
  3473.  
  3474.  show print asm-demangle 
  3475.            Show whether C++ names in assembly listings are printed in mangled 
  3476.            or demangled form. 
  3477.  
  3478.  set demangle-style style 
  3479.            Choose among several encoding schemes used by different compilers to 
  3480.            represent C++ names.  The choices for style are currently: 
  3481.  
  3482.            auto 
  3483.                           Allow GDB to choose a decoding style by inspecting 
  3484.                           your program. 
  3485.  
  3486.            gnu 
  3487.                           Decode based on the gnu C++ compiler (g++) encoding 
  3488.                           algorithm. This is the default. 
  3489.  
  3490.            lucid 
  3491.                           Decode based on the Lucid C++ compiler (lcc) encoding 
  3492.                           algorithm. 
  3493.  
  3494.            arm 
  3495.                           Decode using the algorithm in the C++ Annotated 
  3496.                           Reference Manual. *Warning:* this setting alone is 
  3497.                           not sufficient to allow debugging cfront-generated 
  3498.                           executables.  GDB would require further enhancement 
  3499.                           to permit that. 
  3500.  
  3501.            foo 
  3502.                           Show the list of formats. 
  3503.  
  3504.  show demangle-style 
  3505.            Display the encoding style currently in use for decoding C++ 
  3506.            symbols. 
  3507.  
  3508.  set print object 
  3509.  set print object on 
  3510.            When displaying a pointer to an object, identify the actual 
  3511.            (derived) type of the object rather than the declared type, using 
  3512.            the virtual function table. 
  3513.  
  3514.  set print object off 
  3515.            Display only the declared type of objects, without reference to the 
  3516.            virtual function table.  This is the default setting. 
  3517.  
  3518.  show print object 
  3519.            Show whether actual, or declared, object types are displayed. 
  3520.  
  3521.  set print static-members 
  3522.  set print static-members on 
  3523.            Print static members when displaying a C++ object.  The default is 
  3524.            on. 
  3525.  
  3526.  set print static-members off 
  3527.            Do not print static members when displaying a C++ object. 
  3528.  
  3529.  show print static-members 
  3530.            Show whether C++ static members are printed, or not. 
  3531.  
  3532.  set print vtbl 
  3533.  set print vtbl on 
  3534.            Pretty print C++ virtual function tables.  The default is off. 
  3535.  
  3536.  set print vtbl off 
  3537.            Do not pretty print C++ virtual function tables. 
  3538.  
  3539.  show print vtbl 
  3540.            Show whether C++ virtual function tables are pretty printed, or not. 
  3541.  
  3542.  
  3543. ΓòÉΓòÉΓòÉ 11.8. Value history ΓòÉΓòÉΓòÉ
  3544.  
  3545. Values printed by the print command are saved in the GDB value history.  This 
  3546. allows you to refer to them in other expressions. Values are kept until the 
  3547. symbol table is re-read or discarded (for example with the file or symbol-file 
  3548. commands). When the symbol table changes, the value history is discarded, since 
  3549. the values may contain pointers back to the types defined in the symbol table. 
  3550.  
  3551. The values printed are given history numbers by which you can refer to them. 
  3552. These are successive integers starting with one. print shows you the history 
  3553. number assigned to a value by printing `$num = ' before the value; here num is 
  3554. the history number. 
  3555.  
  3556. To refer to any previous value, use `$' followed by the value's history number. 
  3557. The way print labels its output is designed to remind you of this.  Just $ 
  3558. refers to the most recent value in the history, and $$ refers to the value 
  3559. before that. $$n refers to the nth value from the end; $$2 is the value just 
  3560. prior to $$, $$1 is equivalent to $$, and $$0 is equivalent to $. 
  3561.  
  3562. For example, suppose you have just printed a pointer to a structure and want to 
  3563. see the contents of the structure.  It suffices to type 
  3564.  
  3565. p *$
  3566.  
  3567. If you have a chain of structures where the component next points to the next 
  3568. one, you can print the contents of the next one with this: 
  3569.  
  3570. p *$.next
  3571.  
  3572. You can print successive links in the chain by repeating this command---which 
  3573. you can do by just typing RET. 
  3574.  
  3575. Note that the history records values, not expressions.  If the value of x is 4 
  3576. and you type these commands: 
  3577.  
  3578. print x
  3579. set x=5
  3580.  
  3581. then the value recorded in the value history by the print command remains 4 
  3582. even though the value of x has changed. 
  3583.  
  3584.  show values 
  3585.            Print the last ten values in the value history, with their item 
  3586.            numbers. This is like `p@ $$9' repeated ten times, except that show 
  3587.            values does not change the history. 
  3588.  
  3589.  show values n 
  3590.            Print ten history values centered on history item number n. 
  3591.  
  3592.  show values + 
  3593.            Print ten history values just after the values last printed.  If no 
  3594.            more values are available, show values + produces no display. 
  3595.  
  3596.  Pressing RET to repeat show values n has exactly the same effect as `show 
  3597.  values +'. 
  3598.  
  3599.  
  3600. ΓòÉΓòÉΓòÉ 11.9. Convenience variables ΓòÉΓòÉΓòÉ
  3601.  
  3602. GDB provides convenience variables that you can use within GDB to hold on to a 
  3603. value and refer to it later.  These variables exist entirely within GDB; they 
  3604. are not part of your program, and setting a convenience variable has no direct 
  3605. effect on further execution of your program.  That is why you can use them 
  3606. freely. 
  3607.  
  3608. Convenience variables are prefixed with `$'.  Any name preceded by `$' can be 
  3609. used for a convenience variable, unless it is one of the predefined 
  3610. machine-specific register names (see Registers). (Value history references, in 
  3611. contrast, are numbers preceded by `$'.  See Value history.) 
  3612.  
  3613. You can save a value in a convenience variable with an assignment expression, 
  3614. just as you would set a variable in your program. For example: 
  3615.  
  3616. set $foo = *object_ptr
  3617.  
  3618. would save in $foo the value contained in the object pointed to by object_ptr. 
  3619.  
  3620. Using a convenience variable for the first time creates it, but its value is 
  3621. void until you assign a new value.  You can alter the value with another 
  3622. assignment at any time. 
  3623.  
  3624. Convenience variables have no fixed types.  You can assign a convenience 
  3625. variable any type of value, including structures and arrays, even if that 
  3626. variable already has a value of a different type.  The convenience variable, 
  3627. when used as an expression, has the type of its current value. 
  3628.  
  3629.  show convenience 
  3630.            Print a list of convenience variables used so far, and their values. 
  3631.            Abbreviated show con. 
  3632.  
  3633.  One of the ways to use a convenience variable is as a counter to be 
  3634.  incremented or a pointer to be advanced.  For example, to print a field from 
  3635.  successive elements of an array of structures: 
  3636.  
  3637.   set $i = 0
  3638.   print bar[$i++]->contents
  3639.  
  3640.  Repeat that command by typing RET. 
  3641.  
  3642.  Some convenience variables are created automatically by GDB and given values 
  3643.  likely to be useful. 
  3644.  
  3645.  $_ 
  3646.            The variable $_ is automatically set by the x command to the last 
  3647.            address examined (see Examining memory).  Other commands which 
  3648.            provide a default address for x to examine also set $_ to that 
  3649.            address; these commands include info line and info breakpoint.  The 
  3650.            type of $_ is void * except when set by the x command, in which case 
  3651.            it is a pointer to the type of $__. 
  3652.  
  3653.  $__ 
  3654.            The variable $__ is automatically set by the x command to the value 
  3655.            found in the last address examined.  Its type is chosen to match the 
  3656.            format in which the data was printed. 
  3657.  
  3658.  $_exitcode 
  3659.            The variable $_exitcode is automatically set to the exit code when 
  3660.            the program being debugged terminates. 
  3661.  
  3662.  
  3663. ΓòÉΓòÉΓòÉ 11.10. Registers ΓòÉΓòÉΓòÉ
  3664.  
  3665. You can refer to machine register contents, in expressions, as variables with 
  3666. names starting with `$'.  The names of registers are different for each 
  3667. machine; use info registers to see the names used on your machine. 
  3668.  
  3669.  info registers 
  3670.            Print the names and values of all registers except floating-point 
  3671.            registers (in the selected stack frame). 
  3672.  
  3673.  info all-registers 
  3674.            Print the names and values of all registers, including 
  3675.            floating-point registers. 
  3676.  
  3677.  info registers regname ... 
  3678.            Print the relativized value of each specified register regname. As 
  3679.            discussed in detail below, register values are normally relative to 
  3680.            the selected stack frame.  regname may be any register name valid on 
  3681.            the machine you are using, with or without the initial `$'. 
  3682.  
  3683.  GDB has four ``standard'' register names that are available (in expressions) 
  3684.  on most machines---whenever they do not conflict with an architecture's 
  3685.  canonical mnemonics for registers.  The register names $pc and $sp are used 
  3686.  for the program counter register and the stack pointer.  $fp is used for a 
  3687.  register that contains a pointer to the current stack frame, and $ps is used 
  3688.  for a register that contains the processor status.  For example, you could 
  3689.  print the program counter in hex with 
  3690.  
  3691.   p/x $pc
  3692.  
  3693.  or print the instruction to be executed next with 
  3694.  
  3695.   x/i $pc
  3696.  
  3697.  or add four to the stack pointer(2) with 
  3698.  
  3699.   set $sp += 4
  3700.  
  3701.  Whenever possible, these four standard register names are available on your 
  3702.  machine even though the machine has different canonical mnemonics, so long as 
  3703.  there is no conflict.  The info registers command shows the canonical names. 
  3704.  For example, on the SPARC, info registers displays the processor status 
  3705.  register as $psr but you can also refer to it as $ps. 
  3706.  
  3707.  GDB always considers the contents of an ordinary register as an integer when 
  3708.  the register is examined in this way.  Some machines have special registers 
  3709.  which can hold nothing but floating point; these registers are considered to 
  3710.  have floating point values.  There is no way to refer to the contents of an 
  3711.  ordinary register as floating point value (although you can print it as a 
  3712.  floating point value with `print/f $regname'). 
  3713.  
  3714.  Some registers have distinct ``raw'' and ``virtual'' data formats.  This means 
  3715.  that the data format in which the register contents are saved by the operating 
  3716.  system is not the same one that your program normally sees.  For example, the 
  3717.  registers of the 68881 floating point coprocessor are always saved in 
  3718.  ``extended'' (raw) format, but all C programs expect to work with ``double'' 
  3719.  (virtual) format.  In such cases, GDB normally works with the virtual format 
  3720.  only (the format that makes sense for your program), but the info registers 
  3721.  command prints the data in both formats. 
  3722.  
  3723.  Normally, register values are relative to the selected stack frame (see 
  3724.  Selecting a frame).  This means that you get the value that the register would 
  3725.  contain if all stack frames farther in were exited and their saved registers 
  3726.  restored.  In order to see the true contents of hardware registers, you must 
  3727.  select the innermost frame (with `frame 0'). 
  3728.  
  3729.  However, GDB must deduce where registers are saved, from the machine code 
  3730.  generated by your compiler.  If some registers are not saved, or if GDB is 
  3731.  unable to locate the saved registers, the selected stack frame makes no 
  3732.  difference. 
  3733.  
  3734.  set rstack_high_address address 
  3735.            On AMD 29000 family processors, registers are saved in a separate 
  3736.            ``register stack''.  There is no way for GDB to determine the extent 
  3737.            of this stack.  Normally, GDB just assumes that the stack is ``large 
  3738.            enough''.  This may result in GDB referencing memory locations that 
  3739.            do not exist.  If necessary, you can get around this problem by 
  3740.            specifying the ending address of the register stack with the set 
  3741.            rstack_high_address command.  The argument should be an address, 
  3742.            which you probably want to precede with `0x' to specify in 
  3743.            hexadecimal. 
  3744.  
  3745.  show rstack_high_address 
  3746.            Display the current limit of the register stack, on AMD 29000 family 
  3747.            processors. 
  3748.  
  3749.  
  3750. ΓòÉΓòÉΓòÉ 11.11. Floating point hardware ΓòÉΓòÉΓòÉ
  3751.  
  3752. Depending on the configuration, GDB may be able to give you more information 
  3753. about the status of the floating point hardware. 
  3754.  
  3755.  info float 
  3756.            Display hardware-dependent information about the floating point 
  3757.            unit.  The exact contents and layout vary depending on the floating 
  3758.            point chip.  Currently, `info float' is supported on the ARM and x86 
  3759.            machines. 
  3760.  
  3761.  
  3762. ΓòÉΓòÉΓòÉ 12. Using GDB with Different Languages ΓòÉΓòÉΓòÉ
  3763.  
  3764. Although programming languages generally have common aspects, they are rarely 
  3765. expressed in the same manner.  For instance, in ANSI C, dereferencing a pointer 
  3766. p is accomplished by *p, but in Modula-2, it is accomplished by p^.  Values can 
  3767. also be represented (and displayed) differently.  Hex numbers in C appear as 
  3768. `0x1ae', while in Modula-2 they appear as `1AEH'. 
  3769.  
  3770. Language-specific information is built into GDB for some languages, allowing 
  3771. you to express operations like the above in your program's native language, and 
  3772. allowing GDB to output values in a manner consistent with the syntax of your 
  3773. program's native language.  The language you use to build expressions is called 
  3774. the working language. 
  3775.  
  3776.  Setting                                 Switching between source languages 
  3777.  Show                                    Displaying the language 
  3778.  
  3779.  Checks                                  Type and range checks 
  3780.  
  3781.  Support                                 Supported languages 
  3782.  
  3783.  
  3784. ΓòÉΓòÉΓòÉ 12.1. Switching between source languages ΓòÉΓòÉΓòÉ
  3785.  
  3786. There are two ways to control the working language---either have GDB set it 
  3787. automatically, or select it manually yourself.  You can use the set language 
  3788. command for either purpose.  On startup, GDB defaults to setting the language 
  3789. automatically.  The working language is used to determine how expressions you 
  3790. type are interpreted, how values are printed, etc. 
  3791.  
  3792. In addition to the working language, every source file that GDB knows about has 
  3793. its own working language.  For some object file formats, the compiler might 
  3794. indicate which language a particular source file is in.  However, most of the 
  3795. time GDB infers the language from the name of the file.  The language of a 
  3796. source file controls whether C++ names are demangled---this way backtrace can 
  3797. show each frame appropriately for its own language.  There is no way to set the 
  3798. language of a source file from within GDB. 
  3799.  
  3800. This is most commonly a problem when you use a program, such as cfront or f2c, 
  3801. that generates C but is written in another language.  In that case, make the 
  3802. program use #line directives in its C output; that way GDB will know the 
  3803. correct language of the source code of the original program, and will display 
  3804. that source code, not the generated C code. 
  3805.  
  3806.  Filenames                               Filename extensions and languages. 
  3807.  Manually                                Setting the working language manually 
  3808.  Automatically                           Having GDBN infer the source language 
  3809.  
  3810.  
  3811. ΓòÉΓòÉΓòÉ 12.1.1. List of filename extensions and languages ΓòÉΓòÉΓòÉ
  3812.  
  3813. If a source file name ends in one of the following extensions, then GDB infers 
  3814. that its language is the one indicated. 
  3815.  
  3816.  `.mod' 
  3817.            Modula-2 source file 
  3818.  
  3819.  `.c' 
  3820.            C source file 
  3821.  
  3822.  `.C' 
  3823.  `.cc' 
  3824.  `.cxx' 
  3825.  `.cpp' 
  3826.  `.cp' 
  3827.  `.c++' 
  3828.            C++ source file 
  3829.  
  3830.  `.ch' 
  3831.  `.c186' 
  3832.  `.c286' 
  3833.            CHILL source file. 
  3834.  
  3835.  `.s' 
  3836.  `.S' 
  3837.            Assembler source file.  This actually behaves almost like C, but GDB 
  3838.            does not skip over function prologues when stepping. 
  3839.  
  3840.  
  3841. ΓòÉΓòÉΓòÉ 12.1.2. Setting the working language ΓòÉΓòÉΓòÉ
  3842.  
  3843. If you allow GDB to set the language automatically, expressions are interpreted 
  3844. the same way in your debugging session and your program. 
  3845.  
  3846. If you wish, you may set the language manually.  To do this, issue the command 
  3847. `set language lang', where lang is the name of a language, such as c or 
  3848. modula-2. For a list of the supported languages, type `set language'. 
  3849.  
  3850. Setting the language manually prevents GDB from updating the working language 
  3851. automatically.  This can lead to confusion if you try to debug a program when 
  3852. the working language is not the same as the source language, when an expression 
  3853. is acceptable to both languages---but means different things.  For instance, if 
  3854. the current source file were written in C, and GDB was parsing Modula-2, a 
  3855. command such as: 
  3856.  
  3857. print a = b + c
  3858.  
  3859. might not have the effect you intended.  In C, this means to add b and c and 
  3860. place the result in a.  The result printed would be the value of a.  In 
  3861. Modula-2, this means to compare a to the result of b+c, yielding a BOOLEAN 
  3862. value. 
  3863.  
  3864.  
  3865. ΓòÉΓòÉΓòÉ 12.1.3. Having GDB infer the source language ΓòÉΓòÉΓòÉ
  3866.  
  3867. To have GDB set the working language automatically, use `set language local' or 
  3868. `set language auto'.  GDB then infers the working language.  That is, when your 
  3869. program stops in a frame (usually by encountering a breakpoint), GDB sets the 
  3870. working language to the language recorded for the function in that frame.  If 
  3871. the language for a frame is unknown (that is, if the function or block 
  3872. corresponding to the frame was defined in a source file that does not have a 
  3873. recognized extension), the current working language is not changed, and GDB 
  3874. issues a warning. 
  3875.  
  3876. This may not seem necessary for most programs, which are written entirely in 
  3877. one source language.  However, program modules and libraries written in one 
  3878. source language can be used by a main program written in a different source 
  3879. language.  Using `set language auto' in this case frees you from having to set 
  3880. the working language manually. 
  3881.  
  3882.  
  3883. ΓòÉΓòÉΓòÉ 12.2. Displaying the language ΓòÉΓòÉΓòÉ
  3884.  
  3885. The following commands help you find out which language is the working 
  3886. language, and also what language source files were written in. 
  3887.  
  3888.  show language 
  3889.            Display the current working language.  This is the language you can 
  3890.            use with commands such as print to build and compute expressions 
  3891.            that may involve variables in your program. 
  3892.  
  3893.  info frame 
  3894.            Display the source language for this frame.  This language becomes 
  3895.            the working language if you use an identifier from this frame. See 
  3896.            Information about a frame, to identify the other information listed 
  3897.            here. 
  3898.  
  3899.  info source 
  3900.            Display the source language of this source file. See Examining the 
  3901.            Symbol Table, to identify the other information listed here. 
  3902.  
  3903.  
  3904. ΓòÉΓòÉΓòÉ 12.3. Type and range checking ΓòÉΓòÉΓòÉ
  3905.  
  3906. Warning: In this release, the GDB commands for type and range checking are 
  3907. included, but they do not yet have any effect.  This section documents the 
  3908. intended facilities. 
  3909.  
  3910. Some languages are designed to guard you against making seemingly common errors 
  3911. through a series of compile- and run-time checks.  These include checking the 
  3912. type of arguments to functions and operators, and making sure mathematical 
  3913. overflows are caught at run time.  Checks such as these help to ensure a 
  3914. program's correctness once it has been compiled by eliminating type mismatches, 
  3915. and providing active checks for range errors when your program is running. 
  3916.  
  3917. GDB can check for conditions like the above if you wish. Although GDB does not 
  3918. check the statements in your program, it can check expressions entered directly 
  3919. into GDB for evaluation via the print command, for example.  As with the 
  3920. working language, GDB can also decide whether or not to check automatically 
  3921. based on your program's source language.  See Supported languages, for the 
  3922. default settings of supported languages. 
  3923.  
  3924.  Type Checking                           An overview of type checking 
  3925.  Range Checking                          An overview of range checking 
  3926.  
  3927.  
  3928. ΓòÉΓòÉΓòÉ 12.3.1. An overview of type checking ΓòÉΓòÉΓòÉ
  3929.  
  3930. Some languages, such as Modula-2, are strongly typed, meaning that the 
  3931. arguments to operators and functions have to be of the correct type, otherwise 
  3932. an error occurs.  These checks prevent type mismatch errors from ever causing 
  3933. any run-time problems.  For example, 
  3934.  
  3935. 1 + 2 => 3
  3936. but
  3937. error--> 1 + 2.3
  3938.  
  3939. The second example fails because the CARDINAL 1 is not type-compatible with the 
  3940. REAL 2.3. 
  3941.  
  3942. For the expressions you use in GDB commands, you can tell the GDB type checker 
  3943. to skip checking; to treat any mismatches as errors and abandon the expression; 
  3944. or to only issue warnings when type mismatches occur, but evaluate the 
  3945. expression anyway.  When you choose the last of these, GDB evaluates 
  3946. expressions like the second example above, but also issues a warning. 
  3947.  
  3948. Even if you turn type checking off, there may be other reasons related to type 
  3949. that prevent GDB from evaluating an expression. For instance, GDB does not know 
  3950. how to add an int and a struct foo.  These particular type errors have nothing 
  3951. to do with the language in use, and usually arise from expressions, such as the 
  3952. one described above, which make little sense to evaluate anyway. 
  3953.  
  3954. Each language defines to what degree it is strict about type.  For instance, 
  3955. both Modula-2 and C require the arguments to arithmetical operators to be 
  3956. numbers.  In C, enumerated types and pointers can be represented as numbers, so 
  3957. that they are valid arguments to mathematical operators.  See Supported 
  3958. languages, for further details on specific languages. 
  3959.  
  3960. GDB provides some additional commands for controlling the type checker: 
  3961.  
  3962.  set check type auto 
  3963.            Set type checking on or off based on the current working language. 
  3964.            See Supported languages, for the default settings for each language. 
  3965.  
  3966.  set check type on 
  3967.  set check type off 
  3968.            Set type checking on or off, overriding the default setting for the 
  3969.            current working language.  Issue a warning if the setting does not 
  3970.            match the language default.  If any type mismatches occur in 
  3971.            evaluating an expression while typechecking is on, GDB prints a 
  3972.            message and aborts evaluation of the expression. 
  3973.  
  3974.  set check type warn 
  3975.            Cause the type checker to issue warnings, but to always attempt to 
  3976.            evaluate the expression.  Evaluating the expression may still be 
  3977.            impossible for other reasons.  For example, GDB cannot add numbers 
  3978.            and structures. 
  3979.  
  3980.  show type 
  3981.            Show the current setting of the type checker, and whether or not GDB 
  3982.            is setting it automatically. 
  3983.  
  3984.  
  3985. ΓòÉΓòÉΓòÉ 12.3.2. An overview of range checking ΓòÉΓòÉΓòÉ
  3986.  
  3987. In some languages (such as Modula-2), it is an error to exceed the bounds of a 
  3988. type; this is enforced with run-time checks.  Such range checking is meant to 
  3989. ensure program correctness by making sure computations do not overflow, or 
  3990. indices on an array element access do not exceed the bounds of the array. 
  3991.  
  3992. For expressions you use in GDB commands, you can tell GDB to treat range errors 
  3993. in one of three ways: ignore them, always treat them as errors and abandon the 
  3994. expression, or issue warnings but evaluate the expression anyway. 
  3995.  
  3996. A range error can result from numerical overflow, from exceeding an array index 
  3997. bound, or when you type a constant that is not a member of any type.  Some 
  3998. languages, however, do not treat overflows as an error.  In many 
  3999. implementations of C, mathematical overflow causes the result to ``wrap 
  4000. around'' to lower values---for example, if m is the largest integer value, and 
  4001. s is the smallest, then 
  4002.  
  4003. m + 1 => s
  4004.  
  4005. This, too, is specific to individual languages, and in some cases specific to 
  4006. individual compilers or machines. See Supported languages, for further details 
  4007. on specific languages. 
  4008.  
  4009. GDB provides some additional commands for controlling the range checker: 
  4010.  
  4011.  set check range auto 
  4012.            Set range checking on or off based on the current working language. 
  4013.            See Supported languages, for the default settings for each language. 
  4014.  
  4015.  set check range on 
  4016.  set check range off 
  4017.            Set range checking on or off, overriding the default setting for the 
  4018.            current working language.  A warning is issued if the setting does 
  4019.            not match the language default.  If a range error occurs, then a 
  4020.            message is printed and evaluation of the expression is aborted. 
  4021.  
  4022.  set check range warn 
  4023.            Output messages when the GDB range checker detects a range error, 
  4024.            but attempt to evaluate the expression anyway.  Evaluating the 
  4025.            expression may still be impossible for other reasons, such as 
  4026.            accessing memory that the process does not own (a typical example 
  4027.            from many Unix systems). 
  4028.  
  4029.  show range 
  4030.            Show the current setting of the range checker, and whether or not it 
  4031.            is being set automatically by GDB. 
  4032.  
  4033.  
  4034. ΓòÉΓòÉΓòÉ 12.4. Supported languages ΓòÉΓòÉΓòÉ
  4035.  
  4036. GDB 4 supports C, C++, and Modula-2. Some GDB features may be used in 
  4037. expressions regardless of the language you use: the GDB @ and :: operators, and 
  4038. the `{type}addr' construct ( see Expressions) can be used with the constructs 
  4039. of any supported language. 
  4040.  
  4041. The following sections detail to what degree each source language is supported 
  4042. by GDB.  These sections are not meant to be language tutorials or references, 
  4043. but serve only as a reference guide to what the GDB expression parser accepts, 
  4044. and what input and output formats should look like for different languages. 
  4045. There are many good books written on each of these languages; please look to 
  4046. these for a language reference or tutorial. 
  4047.  
  4048.  C                                       C and C++ 
  4049.  Modula-2                                Modula-2 
  4050.  
  4051.  
  4052. ΓòÉΓòÉΓòÉ 12.4.1. C and C++ ΓòÉΓòÉΓòÉ
  4053.  
  4054. Since C and C++ are so closely related, many features of GDB apply to both 
  4055. languages.  Whenever this is the case, we discuss those languages together. 
  4056.  
  4057. The C++ debugging facilities are jointly implemented by the gnu C++ compiler 
  4058. and GDB.  Therefore, to debug your C++ code effectively, you must compile your 
  4059. C++ programs with the gnu C++ compiler, g++. 
  4060.  
  4061. For best results when debugging C++ programs, use the stabs debugging format. 
  4062. You can select that format explicitly with the g++ command-line options 
  4063. `-gstabs' or `-gstabs+'.  See Options for Debugging Your Program or gnu CC, for 
  4064. more information. 
  4065.  
  4066.  C Operators                             C operators 
  4067.  
  4068.  
  4069.  C Constants                             C constants 
  4070.  Debugging C                             GDBN and C 
  4071.  
  4072.  C Operators                             C and C++ operators 
  4073.  C Constants                             C and C++ constants 
  4074.  Cplus expressions                       C++ expressions 
  4075.  C Defaults                              Default settings for C and C++ 
  4076.  
  4077.  C Checks                                C and C++ type and range checks 
  4078.  
  4079.  Debugging C                             GDBN and C 
  4080.  Debugging C plus plus                   Special features for C++ 
  4081.  
  4082.  
  4083. ΓòÉΓòÉΓòÉ 12.4.1.1. C and C++ operators ΓòÉΓòÉΓòÉ
  4084.  
  4085. Operators must be defined on values of specific types.  For instance, 
  4086.  
  4087. + is defined on numbers, but not on structures.  Operators are often defined on 
  4088. groups of types. 
  4089.  
  4090. For the purposes of C and C++, the following definitions hold: 
  4091.  
  4092.      Integral types include int with any of its storage-class specifiers; 
  4093.       char; and enum. 
  4094.  
  4095.      Floating-point types include float and double. 
  4096.  
  4097.      Pointer types include all types defined as (type *). 
  4098.  
  4099.      Scalar types include all of the above. 
  4100.  
  4101.  The following operators are supported.  They are listed here in order of 
  4102.  increasing precedence: 
  4103.  
  4104.  , 
  4105.            The comma or sequencing operator.  Expressions in a comma-separated 
  4106.            list are evaluated from left to right, with the result of the entire 
  4107.            expression being the last expression evaluated. 
  4108.  
  4109.  = 
  4110.            Assignment.  The value of an assignment expression is the value 
  4111.            assigned.  Defined on scalar types. 
  4112.  
  4113.  op= 
  4114.            Used in an expression of the form a op= b, and translated to a = a 
  4115.            op b. op= and = have the same precendence. op is any one of the 
  4116.            operators |, ^, &, <<, >>, +, -, *, /, %. 
  4117.  
  4118.  ?: 
  4119.            The ternary operator.  a ? b : c can be thought of as:  if a then b 
  4120.            else c.  a should be of an integral type. 
  4121.  
  4122.  || 
  4123.            Logical or.  Defined on integral types. 
  4124.  
  4125.  && 
  4126.            Logical and.  Defined on integral types. 
  4127.  
  4128.  | 
  4129.            Bitwise or.  Defined on integral types. 
  4130.  
  4131.  ^ 
  4132.            Bitwise exclusive-or.  Defined on integral types. 
  4133.  
  4134.  & 
  4135.            Bitwise and.  Defined on integral types. 
  4136.  
  4137.  ==, != 
  4138.            Equality and inequality.  Defined on scalar types.  The value of 
  4139.            these expressions is 0 for false and non-zero for true. 
  4140.  
  4141.  <, >, <=, >= 
  4142.            Less than, greater than, less than or equal, greater than or equal. 
  4143.            Defined on scalar types.  The value of these expressions is 0 for 
  4144.            false and non-zero for true. 
  4145.  
  4146.  <<, >> 
  4147.            left shift, and right shift.  Defined on integral types. 
  4148.  
  4149.  @ 
  4150.            The GDB ``artificial array'' operator (see Expressions). 
  4151.  
  4152.  +, - 
  4153.            Addition and subtraction.  Defined on integral types, floating-point 
  4154.            types and pointer types. 
  4155.  
  4156.  *, /, % 
  4157.            Multiplication, division, and modulus.  Multiplication and division 
  4158.            are defined on integral and floating-point types.  Modulus is 
  4159.            defined on integral types. 
  4160.  
  4161.  ++, -- 
  4162.            Increment and decrement.  When appearing before a variable, the 
  4163.            operation is performed before the variable is used in an expression; 
  4164.            when appearing after it, the variable's value is used before the 
  4165.            operation takes place. 
  4166.  
  4167.  * 
  4168.            Pointer dereferencing.  Defined on pointer types.  Same precedence 
  4169.            as ++. 
  4170.  
  4171.  & 
  4172.            Address operator.  Defined on variables.  Same precedence as ++. 
  4173.  
  4174.            For debugging C++, GDB implements a use of `&' beyond what is 
  4175.            allowed in the C++ language itself: you can use `&(&ref)' (or, if 
  4176.            you prefer, simply `&&ref') to examine the address where a C++ 
  4177.            reference variable (declared with `&ref') is stored. 
  4178.  
  4179.  - 
  4180.            Negative.  Defined on integral and floating-point types.  Same 
  4181.            precedence as ++. 
  4182.  
  4183.  ! 
  4184.            Logical negation.  Defined on integral types.  Same precedence as 
  4185.            ++. 
  4186.  
  4187.  ~ 
  4188.            Bitwise complement operator.  Defined on integral types.  Same 
  4189.            precedence as ++. 
  4190.  
  4191.  ., -> 
  4192.            Structure member, and pointer-to-structure member.  For convenience, 
  4193.            GDB regards the two as equivalent, choosing whether to dereference a 
  4194.            pointer based on the stored type information. Defined on struct and 
  4195.            union data. 
  4196.  
  4197.  [] 
  4198.            Array indexing.  a[i] is defined as *(a+i).  Same precedence as ->. 
  4199.  
  4200.  () 
  4201.            Function parameter list.  Same precedence as ->. 
  4202.  
  4203.  :: 
  4204.            C++ scope resolution operator.  Defined on struct, union, and class 
  4205.            types. 
  4206.  
  4207.  :: 
  4208.            Doubled colons also represent the GDB scope operator ( see 
  4209.            Expressions). Same precedence as ::, above. 
  4210.  
  4211.  
  4212. ΓòÉΓòÉΓòÉ 12.4.1.2. C and C++ constants ΓòÉΓòÉΓòÉ
  4213.  
  4214. GDB allows you to express the constants of C and C++ in the following ways: 
  4215.  
  4216.      Integer constants are a sequence of digits.  Octal constants are 
  4217.       specified by a leading `0' (i.e. zero), and hexadecimal constants by a 
  4218.       leading `0x' or `0X'.  Constants may also end with a letter `l', 
  4219.       specifying that the constant should be treated as a long value. 
  4220.  
  4221.      Floating point constants are a sequence of digits, followed by a decimal 
  4222.       point, followed by a sequence of digits, and optionally followed by an 
  4223.       exponent.  An exponent is of the form: `e[[+]|-]nnn', where nnn is 
  4224.       another sequence of digits.  The `+' is optional for positive exponents. 
  4225.  
  4226.      Enumerated constants consist of enumerated identifiers, or their integral 
  4227.       equivalents. 
  4228.  
  4229.      Character constants are a single character surrounded by single quotes 
  4230.       ('), or a number---the ordinal value of the corresponding character 
  4231.       (usually its ASCII value).  Within quotes, the single character may be 
  4232.       represented by a letter or by escape sequences, which are of the form 
  4233.       `\nnn', where nnn is the octal representation of the character's ordinal 
  4234.       value; or of the form `\x', where `x' is a predefined special 
  4235.       character---for example, `\n' for newline. 
  4236.  
  4237.      String constants are a sequence of character constants surrounded by 
  4238.       double quotes ("). 
  4239.  
  4240.      Pointer constants are an integral value.  You can also write pointers to 
  4241.       constants using the C operator `&'. 
  4242.  
  4243.      Array constants are comma-separated lists surrounded by braces `{' and 
  4244.       `}'; for example, `{1,2,3}' is a three-element array of integers, 
  4245.       `{{1,2}, {3,4}, {5,6}}' is a three-by-two array, and `{&"hi", &"there", 
  4246.       &"fred"}' is a three-element array of pointers. 
  4247.  
  4248.  
  4249. ΓòÉΓòÉΓòÉ 12.4.1.3. C++ expressions ΓòÉΓòÉΓòÉ
  4250.  
  4251. GDB expression handling has a number of extensions to interpret a significant 
  4252. subset of C++ expressions. 
  4253.  
  4254. Warning: GDB can only debug C++ code if you compile with the gnu C++ compiler. 
  4255. Moreover, C++ debugging depends on the use of additional debugging information 
  4256. in the symbol table, and thus requires special support.  GDB has this support 
  4257. only with the stabs debug format.  In particular, if your compiler generates 
  4258. a.out, MIPS ecoff, RS/6000 xcoff, or elf with stabs extensions to the symbol 
  4259. table, these facilities are all available.  (With gnu CC, you can use the 
  4260. `-gstabs' option to request stabs debugging extensions explicitly.)  Where the 
  4261. object code format is standard coff or dwarf in elf, on the other hand, most of 
  4262. the C++ support in GDB does not work. 
  4263.  
  4264.    1. Member function calls are allowed; you can use expressions like 
  4265.  
  4266.             count = aml->GetOriginal(x, y)
  4267.  
  4268.    2. While a member function is active (in the selected stack frame), your 
  4269.       expressions have the same namespace available as the member function; 
  4270.       that is, GDB allows implicit references to the class instance pointer 
  4271.       this following the same rules as C++. 
  4272.  
  4273.    3. You can call overloaded functions; GDB resolves the function call to the 
  4274.       right definition, with one restriction---you must use arguments of the 
  4275.       type required by the function that you want to call. GDB does not perform 
  4276.       conversions requiring constructors or user-defined type operators. 
  4277.  
  4278.    4. GDB understands variables declared as C++ references; you can use them in 
  4279.       expressions just as you do in C++ source---they are automatically 
  4280.       dereferenced. 
  4281.  
  4282.       In the parameter list shown when GDB displays a frame, the values of 
  4283.       reference variables are not displayed (unlike other variables); this 
  4284.       avoids clutter, since references are often used for large structures. The 
  4285.       address of a reference variable is always shown, unless you have 
  4286.       specified `set print address off'. 
  4287.  
  4288.    5. GDB supports the C++ name resolution operator ::---your expressions can 
  4289.       use it just as expressions in your program do.  Since one scope may be 
  4290.       defined in another, you can use :: repeatedly if necessary, for example 
  4291.       in an expression like `scope1::scope2::name'.  GDB also allows resolving 
  4292.       name scope by reference to source files, in both C and C++ debugging (see 
  4293.       Program variables). 
  4294.  
  4295.  
  4296. ΓòÉΓòÉΓòÉ 12.4.1.4. C and C++ defaults ΓòÉΓòÉΓòÉ
  4297.  
  4298. If you allow GDB to set type and range checking automatically, they both 
  4299. default to off whenever the working language changes to C or C++.  This happens 
  4300. regardless of whether you or GDB selects the working language. 
  4301.  
  4302. If you allow GDB to set the language automatically, it recognizes source files 
  4303. whose names end with `.c', `.C', or `.cc', and when GDB enters code compiled 
  4304. from one of these files, it sets the working language to C or C++. See Having 
  4305. GDB infer the source language, for further details. 
  4306.  
  4307.  
  4308. ΓòÉΓòÉΓòÉ 12.4.1.5. C and C++ type and range checks ΓòÉΓòÉΓòÉ
  4309.  
  4310. By default, when GDB parses C or C++ expressions, type checking is not used. 
  4311. However, if you turn type checking on, GDB considers two variables type 
  4312. equivalent if: 
  4313.  
  4314.      The two variables are structured and have the same structure, union, or 
  4315.       enumerated tag. 
  4316.  
  4317.      The two variables have the same type name, or types that have been 
  4318.       declared equivalent through typedef. 
  4319.  
  4320.  Range checking, if turned on, is done on mathematical operations.  Array 
  4321.  indices are not checked, since they are often used to index a pointer that is 
  4322.  not itself an array. 
  4323.  
  4324.  
  4325. ΓòÉΓòÉΓòÉ 12.4.1.6. GDB and C ΓòÉΓòÉΓòÉ
  4326.  
  4327. The set print union and show print union commands apply to 
  4328.  
  4329. the union type.  When set to `on', any union that is inside a struct or class 
  4330. is also printed. Otherwise, it appears as `{...}'. 
  4331.  
  4332. The @ operator aids in the debugging of dynamic arrays, formed with pointers 
  4333. and a memory allocation function. See Expressions. 
  4334.  
  4335.  
  4336. ΓòÉΓòÉΓòÉ 12.4.1.7. GDB features for C++ ΓòÉΓòÉΓòÉ
  4337.  
  4338. Some GDB commands are particularly useful with C++, and some are designed 
  4339. specifically for use with C++.  Here is a summary: 
  4340.  
  4341.  breakpoint menus 
  4342.            When you want a breakpoint in a function whose name is overloaded, 
  4343.            GDB breakpoint menus help you specify which function definition you 
  4344.            want.  See Breakpoint menus. 
  4345.  
  4346.  rbreak regex 
  4347.            Setting breakpoints using regular expressions is helpful for setting 
  4348.            breakpoints on overloaded functions that are not members of any 
  4349.            special classes. See Setting breakpoints. 
  4350.  
  4351.  catch exceptions 
  4352.  info catch 
  4353.            Debug C++ exception handling using these commands. See Breakpoints 
  4354.            and exceptions. 
  4355.  
  4356.  ptype typename 
  4357.            Print inheritance relationships as well as other information for 
  4358.            type typename. See Examining the Symbol Table. 
  4359.  
  4360.  set print demangle 
  4361.  show print demangle 
  4362.  set print asm-demangle 
  4363.  show print asm-demangle 
  4364.            Control whether C++ symbols display in their source form, both when 
  4365.            displaying code as C++ source and when displaying disassemblies. See 
  4366.            Print settings. 
  4367.  
  4368.  set print object 
  4369.  show print object 
  4370.            Choose whether to print derived (actual) or declared types of 
  4371.            objects. See Print settings. 
  4372.  
  4373.  set print vtbl 
  4374.  show print vtbl 
  4375.            Control the format for printing virtual function tables. See Print 
  4376.            settings. 
  4377.  
  4378.  Overloaded symbol names 
  4379.            You can specify a particular definition of an overloaded symbol, 
  4380.            using the same notation that is used to declare such symbols in C++: 
  4381.            type symbol(types) rather than just symbol.  You can also use the 
  4382.            GDB command-line word completion facilities to list the available 
  4383.            choices, or to finish the type list for you. See Command completion, 
  4384.            for details on how to do this. 
  4385.  
  4386.  
  4387. ΓòÉΓòÉΓòÉ 12.4.2. Modula-2 ΓòÉΓòÉΓòÉ
  4388.  
  4389. The extensions made to GDB to support Modula-2 only support output from the gnu 
  4390. Modula-2 compiler (which is currently being developed).  Other Modula-2 
  4391. compilers are not currently supported, and attempting to debug executables 
  4392. produced by them is most likely to give an error as GDB reads in the 
  4393. executable's symbol table. 
  4394.  
  4395.  M2 Operators                            Built-in operators 
  4396.  Built-In Func/Proc                      Built-in functions and procedures 
  4397.  M2 Constants                            Modula-2 constants 
  4398.  M2 Defaults                             Default settings for Modula-2 
  4399.  Deviations                              Deviations from standard Modula-2 
  4400.  M2 Checks                               Modula-2 type and range checks 
  4401.  M2 Scope                                The scope operators :: and . 
  4402.  GDB/M2                                  GDBN and Modula-2 
  4403.  
  4404.  
  4405. ΓòÉΓòÉΓòÉ 12.4.2.1. Operators ΓòÉΓòÉΓòÉ
  4406.  
  4407. Operators must be defined on values of specific types.  For instance, + is 
  4408. defined on numbers, but not on structures.  Operators are often defined on 
  4409. groups of types.  For the purposes of Modula-2, the following definitions hold: 
  4410.  
  4411.      Integral types consist of INTEGER, CARDINAL, and their subranges. 
  4412.  
  4413.      Character types consist of CHAR and its subranges. 
  4414.  
  4415.      Floating-point types consist of REAL. 
  4416.  
  4417.      Pointer types consist of anything declared as POINTER TO type. 
  4418.  
  4419.      Scalar types consist of all of the above. 
  4420.  
  4421.      Set types consist of SET and BITSET types. 
  4422.  
  4423.      Boolean types consist of BOOLEAN. 
  4424.  
  4425.  The following operators are supported, and appear in order of increasing 
  4426.  precedence: 
  4427.  
  4428.  , 
  4429.            Function argument or array index separator. 
  4430.  
  4431.  := 
  4432.            Assignment.  The value of var := value is value. 
  4433.  
  4434.  <, > 
  4435.            Less than, greater than on integral, floating-point, or enumerated 
  4436.            types. 
  4437.  
  4438.  <=, >= 
  4439.            Less than, greater than, less than or equal to, greater than or 
  4440.            equal to on integral, floating-point and enumerated types, or set 
  4441.            inclusion on set types.  Same precedence as <. 
  4442.  
  4443.  =, <>, # 
  4444.            Equality and two ways of expressing inequality, valid on scalar 
  4445.            types. Same precedence as <.  In GDB scripts, only <> is available 
  4446.            for inequality, since # conflicts with the script comment character. 
  4447.  
  4448.  IN 
  4449.            Set membership.  Defined on set types and the types of their 
  4450.            members. Same precedence as <. 
  4451.  
  4452.  OR 
  4453.            Boolean disjunction.  Defined on boolean types. 
  4454.  
  4455.  AND, & 
  4456.            Boolean conjuction.  Defined on boolean types. 
  4457.  
  4458.  @ 
  4459.            The GDB ``artificial array'' operator (see Expressions). 
  4460.  
  4461.  +, - 
  4462.            Addition and subtraction on integral and floating-point types, or 
  4463.            union and difference on set types. 
  4464.  
  4465.  * 
  4466.            Multiplication on integral and floating-point types, or set 
  4467.            intersection on set types. 
  4468.  
  4469.  / 
  4470.            Division on floating-point types, or symmetric set difference on set 
  4471.            types.  Same precedence as *. 
  4472.  
  4473.  DIV, MOD 
  4474.            Integer division and remainder.  Defined on integral types.  Same 
  4475.            precedence as *. 
  4476.  
  4477.  - 
  4478.            Negative. Defined on INTEGER and REAL data. 
  4479.  
  4480.  ^ 
  4481.            Pointer dereferencing.  Defined on pointer types. 
  4482.  
  4483.  NOT 
  4484.            Boolean negation.  Defined on boolean types.  Same precedence as ^. 
  4485.  
  4486.  . 
  4487.            RECORD field selector.  Defined on RECORD data.  Same precedence as 
  4488.            ^. 
  4489.  
  4490.  [] 
  4491.            Array indexing.  Defined on ARRAY data.  Same precedence as ^. 
  4492.  
  4493.  () 
  4494.            Procedure argument list.  Defined on PROCEDURE objects.  Same 
  4495.            precedence as ^. 
  4496.  
  4497.  ::, . 
  4498.            GDB and Modula-2 scope operators. 
  4499.  
  4500.  Warning: Sets and their operations are not yet supported, so GDB treats the 
  4501.  use of the operator IN, or the use of operators +, -, *, /, =, , <>, #, <=, 
  4502.  and >= on sets as an error. 
  4503.  
  4504.  
  4505. ΓòÉΓòÉΓòÉ 12.4.2.2. Built-in functions and procedures ΓòÉΓòÉΓòÉ
  4506.  
  4507. Modula-2 also makes available several built-in procedures and functions. In 
  4508. describing these, the following metavariables are used: 
  4509.  
  4510.  a 
  4511.            represents an ARRAY variable. 
  4512.  
  4513.  c 
  4514.            represents a CHAR constant or variable. 
  4515.  
  4516.  i 
  4517.            represents a variable or constant of integral type. 
  4518.  
  4519.  m 
  4520.            represents an identifier that belongs to a set.  Generally used in 
  4521.            the same function with the metavariable s.  The type of s should be 
  4522.            SET OF mtype (where mtype is the type of m). 
  4523.  
  4524.  n 
  4525.            represents a variable or constant of integral or floating-point 
  4526.            type. 
  4527.  
  4528.  r 
  4529.            represents a variable or constant of floating-point type. 
  4530.  
  4531.  t 
  4532.            represents a type. 
  4533.  
  4534.  v 
  4535.            represents a variable. 
  4536.  
  4537.  x 
  4538.            represents a variable or constant of one of many types.  See the 
  4539.            explanation of the function for details. 
  4540.  
  4541.  All Modula-2 built-in procedures also return a result, described below. 
  4542.  
  4543.  ABS(n) 
  4544.            Returns the absolute value of n. 
  4545.  
  4546.  CAP(c) 
  4547.            If c is a lower case letter, it returns its upper case equivalent, 
  4548.            otherwise it returns its argument 
  4549.  
  4550.  CHR(i) 
  4551.            Returns the character whose ordinal value is i. 
  4552.  
  4553.  DEC(v) 
  4554.            Decrements the value in the variable v.  Returns the new value. 
  4555.  
  4556.  DEC(v,i) 
  4557.            Decrements the value in the variable v by i.  Returns the new value. 
  4558.  
  4559.  EXCL(m,s) 
  4560.            Removes the element m from the set s.  Returns the new set. 
  4561.  
  4562.  FLOAT(i) 
  4563.            Returns the floating point equivalent of the integer i. 
  4564.  
  4565.  HIGH(a) 
  4566.            Returns the index of the last member of a. 
  4567.  
  4568.  INC(v) 
  4569.            Increments the value in the variable v.  Returns the new value. 
  4570.  
  4571.  INC(v,i) 
  4572.            Increments the value in the variable v by i.  Returns the new value. 
  4573.  
  4574.  INCL(m,s) 
  4575.            Adds the element m to the set s if it is not already there.  Returns 
  4576.            the new set. 
  4577.  
  4578.  MAX(t) 
  4579.            Returns the maximum value of the type t. 
  4580.  
  4581.  MIN(t) 
  4582.            Returns the minimum value of the type t. 
  4583.  
  4584.  ODD(i) 
  4585.            Returns boolean TRUE if i is an odd number. 
  4586.  
  4587.  ORD(x) 
  4588.            Returns the ordinal value of its argument.  For example, the ordinal 
  4589.            value of a character is its ASCII value (on machines supporting the 
  4590.            ASCII character set).  x must be of an ordered type, which include 
  4591.            integral, character and enumerated types. 
  4592.  
  4593.  SIZE(x) 
  4594.            Returns the size of its argument.  x can be a variable or a type. 
  4595.  
  4596.  TRUNC(r) 
  4597.            Returns the integral part of r. 
  4598.  
  4599.  VAL(t,i) 
  4600.            Returns the member of the type t whose ordinal value is i. 
  4601.  
  4602.  Warning:  Sets and their operations are not yet supported, so GDB treats the 
  4603.  use of procedures INCL and EXCL as an error. 
  4604.  
  4605.  
  4606. ΓòÉΓòÉΓòÉ 12.4.2.3. Constants ΓòÉΓòÉΓòÉ
  4607.  
  4608. GDB allows you to express the constants of Modula-2 in the following ways: 
  4609.  
  4610.      Integer constants are simply a sequence of digits.  When used in an 
  4611.       expression, a constant is interpreted to be type-compatible with the rest 
  4612.       of the expression.  Hexadecimal integers are specified by a trailing `H', 
  4613.       and octal integers by a trailing `B'. 
  4614.  
  4615.      Floating point constants appear as a sequence of digits, followed by a 
  4616.       decimal point and another sequence of digits.  An optional exponent can 
  4617.       then be specified, in the form `E[+|-]nnn', where `[+|-]nnn' is the 
  4618.       desired exponent.  All of the digits of the floating point constant must 
  4619.       be valid decimal (base 10) digits. 
  4620.  
  4621.      Character constants consist of a single character enclosed by a pair of 
  4622.       like quotes, either single (') or double (").  They may also be expressed 
  4623.       by their ordinal value (their ASCII value, usually) followed by a `C'. 
  4624.  
  4625.      String constants consist of a sequence of characters enclosed by a pair 
  4626.       of like quotes, either single (') or double ("). Escape sequences in the 
  4627.       style of C are also allowed. See C and C++ constants, for a brief 
  4628.       explanation of escape sequences. 
  4629.  
  4630.      Enumerated constants consist of an enumerated identifier. 
  4631.  
  4632.      Boolean constants consist of the identifiers TRUE and FALSE. 
  4633.  
  4634.      Pointer constants consist of integral values only. 
  4635.  
  4636.      Set constants are not yet supported. 
  4637.  
  4638.  
  4639. ΓòÉΓòÉΓòÉ 12.4.2.4. Modula-2 defaults ΓòÉΓòÉΓòÉ
  4640.  
  4641. If type and range checking are set automatically by GDB, they both default to 
  4642. on whenever the working language changes to Modula-2.  This happens regardless 
  4643. of whether you, or GDB, selected the working language. 
  4644.  
  4645. If you allow GDB to set the language automatically, then entering code compiled 
  4646. from a file whose name ends with `.mod' sets the working language to Modula-2. 
  4647. See Having GDB set the language automatically, for further details. 
  4648.  
  4649.  
  4650. ΓòÉΓòÉΓòÉ 12.4.2.5. Deviations from standard Modula-2 ΓòÉΓòÉΓòÉ
  4651.  
  4652. A few changes have been made to make Modula-2 programs easier to debug. This is 
  4653. done primarily via loosening its type strictness: 
  4654.  
  4655.      Unlike in standard Modula-2, pointer constants can be formed by integers. 
  4656.       This allows you to modify pointer variables during debugging.  (In 
  4657.       standard Modula-2, the actual address contained in a pointer variable is 
  4658.       hidden from you; it can only be modified through direct assignment to 
  4659.       another pointer variable or expression that returned a pointer.) 
  4660.  
  4661.      C escape sequences can be used in strings and characters to represent 
  4662.       non-printable characters.  GDB prints out strings with these escape 
  4663.       sequences embedded.  Single non-printable characters are printed using 
  4664.       the `CHR(nnn)' format. 
  4665.  
  4666.      The assignment operator (:=) returns the value of its right-hand 
  4667.       argument. 
  4668.  
  4669.      All built-in procedures both modify and return their argument. 
  4670.  
  4671.  
  4672. ΓòÉΓòÉΓòÉ 12.4.2.6. Modula-2 type and range checks ΓòÉΓòÉΓòÉ
  4673.  
  4674. Warning: in this release, GDB does not yet perform type or range checking. 
  4675.  
  4676. GDB considers two Modula-2 variables type equivalent if: 
  4677.  
  4678.      They are of types that have been declared equivalent via a TYPE t1 = t2 
  4679.       statement 
  4680.  
  4681.      They have been declared on the same line.  (Note:  This is true of the 
  4682.       gnu Modula-2 compiler, but it may not be true of other compilers.) 
  4683.  
  4684.  As long as type checking is enabled, any attempt to combine variables whose 
  4685.  types are not equivalent is an error. 
  4686.  
  4687.  Range checking is done on all mathematical operations, assignment, array index 
  4688.  bounds, and all built-in functions and procedures. 
  4689.  
  4690.  
  4691. ΓòÉΓòÉΓòÉ 12.4.2.7. The scope operators :: and . ΓòÉΓòÉΓòÉ
  4692.  
  4693. There are a few subtle differences between the Modula-2 scope operator 
  4694.  
  4695. (.) and the GDB scope operator (::).  The two have similar syntax: 
  4696.  
  4697.  
  4698. module . id
  4699. scope :: id
  4700.  
  4701. where scope is the name of a module or a procedure, module the name of a 
  4702. module, and id is any declared identifier within your program, except another 
  4703. module. 
  4704.  
  4705. Using the :: operator makes GDB search the scope specified by scope for the 
  4706. identifier id.  If it is not found in the specified scope, then GDB searches 
  4707. all scopes enclosing the one specified by scope. 
  4708.  
  4709. Using the . operator makes GDB search the current scope for the identifier 
  4710. specified by id that was imported from the definition module specified by 
  4711. module.  With this operator, it is an error if the identifier id was not 
  4712. imported from definition module module, or if id is not an identifier in 
  4713. module. 
  4714.  
  4715.  
  4716. ΓòÉΓòÉΓòÉ 12.4.2.8. GDB and Modula-2 ΓòÉΓòÉΓòÉ
  4717.  
  4718. Some GDB commands have little use when debugging Modula-2 programs. Five 
  4719. subcommands of set print and show print apply specifically to C and C++: 
  4720. `vtbl', `demangle', `asm-demangle', `object', and `union'.  The first four 
  4721. apply to C++, and the last to the C union type, which has no direct analogue in 
  4722. Modula-2. 
  4723.  
  4724. The @ operator (see Expressions), while available while using any language, is 
  4725. not useful with Modula-2.  Its intent is to aid the debugging of dynamic 
  4726. arrays, which cannot be created in Modula-2 as they can in C or C++.  However, 
  4727. because an address can be specified by an integral constant, the construct 
  4728. `{type}adrexp' is still useful.  (see Expressions) 
  4729.  
  4730. In GDB scripts, the Modula-2 inequality operator # is interpreted as the 
  4731. beginning of a comment.  Use <> instead. 
  4732.  
  4733.  
  4734. ΓòÉΓòÉΓòÉ 13. Examining the Symbol Table ΓòÉΓòÉΓòÉ
  4735.  
  4736. The commands described in this section allow you to inquire about the symbols 
  4737. (names of variables, functions and types) defined in your program.  This 
  4738. information is inherent in the text of your program and does not change as your 
  4739. program executes.  GDB finds it in your program's symbol table, in the file 
  4740. indicated when you started GDB (see Choosing files), or by one of the 
  4741. file-management commands (see Commands to specify files). 
  4742.  
  4743. Occasionally, you may need to refer to symbols that contain unusual characters, 
  4744. which GDB ordinarily treats as word delimiters.  The most frequent case is in 
  4745. referring to static variables in other source files (see Program variables). 
  4746. File names are recorded in object files as debugging symbols, but GDB would 
  4747. ordinarily parse a typical file name, like `foo.c', as the three words `foo' 
  4748. `.' `c'.  To allow GDB to recognize `foo.c' as a single symbol, enclose it in 
  4749. single quotes; for example, 
  4750.  
  4751. p 'foo.c'::x
  4752.  
  4753. looks up the value of x in the scope of the file `foo.c'. 
  4754.  
  4755.  info address symbol 
  4756.            Describe where the data for symbol is stored.  For a register 
  4757.            variable, this says which register it is kept in.  For a 
  4758.            non-register local variable, this prints the stack-frame offset at 
  4759.            which the variable is always stored. 
  4760.  
  4761.            Note the contrast with `print &symbol', which does not work at all 
  4762.            for a register variable, and for a stack local variable prints the 
  4763.            exact address of the current instantiation of the variable. 
  4764.  
  4765.  whatis exp 
  4766.            Print the data type of expression exp.  exp is not actually 
  4767.            evaluated, and any side-effecting operations (such as assignments or 
  4768.            function calls) inside it do not take place. See Expressions. 
  4769.  
  4770.  whatis 
  4771.            Print the data type of $, the last value in the value history. 
  4772.  
  4773.  ptype typename 
  4774.            Print a description of data type typename.  typename may be the name 
  4775.            of a type, or for C code it may have the form `class class-name', 
  4776.            `struct struct-tag', `union union-tag' or `enum enum-tag'. 
  4777.  
  4778.  ptype exp 
  4779.  ptype 
  4780.            Print a description of the type of expression exp.  ptype differs 
  4781.            from whatis by printing a detailed description, instead of just the 
  4782.            name of the type. 
  4783.  
  4784.            For example, for this variable declaration: 
  4785.  
  4786.                       struct complex {double real; double imag;} v;
  4787.  
  4788.            the two commands give this output: 
  4789.  
  4790.                       (gdb) whatis v
  4791.                       type = struct complex
  4792.                       (gdb) ptype v
  4793.                       type = struct complex {
  4794.                           double real;
  4795.                           double imag;
  4796.                       }
  4797.  
  4798.            As with whatis, using ptype without an argument refers to the type 
  4799.            of $, the last value in the value history. 
  4800.  
  4801.  info types regexp 
  4802.  info types 
  4803.            Print a brief description of all types whose name matches regexp (or 
  4804.            all types in your program, if you supply no argument).  Each 
  4805.            complete typename is matched as though it were a complete line; 
  4806.            thus, `i type value' gives information on all types in your program 
  4807.            whose name includes the string value, but `i type ^value$' gives 
  4808.            information only on types whose complete name is value. 
  4809.  
  4810.            This command differs from ptype in two ways: first, like whatis, it 
  4811.            does not print a detailed description; second, it lists all source 
  4812.            files where a type is defined. 
  4813.  
  4814.  info source 
  4815.            Show the name of the current source file---that is, the source file 
  4816.            for the function containing the current point of execution---and the 
  4817.            language it was written in. 
  4818.  
  4819.  info sources 
  4820.            Print the names of all source files in your program for which there 
  4821.            is debugging information, organized into two lists: files whose 
  4822.            symbols have already been read, and files whose symbols will be read 
  4823.            when needed. 
  4824.  
  4825.  info functions 
  4826.            Print the names and data types of all defined functions. 
  4827.  
  4828.  info functions regexp 
  4829.            Print the names and data types of all defined functions whose names 
  4830.            contain a match for regular expression regexp. Thus, `info fun step' 
  4831.            finds all functions whose names include step; `info fun ^step' finds 
  4832.            those whose names start with step. 
  4833.  
  4834.  info variables 
  4835.            Print the names and data types of all variables that are declared 
  4836.            outside of functions (i.e., excluding local variables). 
  4837.  
  4838.  info variables regexp 
  4839.            Print the names and data types of all variables (except for local 
  4840.            variables) whose names contain a match for regular expression 
  4841.            regexp. 
  4842.  
  4843.            Some systems allow individual object files that make up your program 
  4844.            to be replaced without stopping and restarting your program. For 
  4845.            example, in VxWorks you can simply recompile a defective object file 
  4846.            and keep on running. If you are running on one of these systems, you 
  4847.            can allow GDB to reload the symbols for automatically relinked 
  4848.            modules: 
  4849.  
  4850.            set symbol-reloading on 
  4851.                           Replace symbol definitions for the corresponding 
  4852.                           source file when an object file with a particular 
  4853.                           name is seen again. 
  4854.  
  4855.            set symbol-reloading off 
  4856.                           Do not replace symbol definitions when 
  4857.                           re-encountering object files of the same name.  This 
  4858.                           is the default state; if you are not running on a 
  4859.                           system that permits automatically relinking modules, 
  4860.                           you should leave symbol-reloading off, since 
  4861.                           otherwise GDB may discard symbols when linking large 
  4862.                           programs, that may contain several modules (from 
  4863.                           different directories or libraries) with the same 
  4864.                           name. 
  4865.  
  4866.            show symbol-reloading 
  4867.                           Show the current on or off setting. 
  4868.  
  4869.  maint print symbols filename 
  4870.  maint print psymbols filename 
  4871.  maint print msymbols filename 
  4872.            Write a dump of debugging symbol data into the file filename. These 
  4873.            commands are used to debug the GDB symbol-reading code.  Only 
  4874.            symbols with debugging data are included.  If you use `maint print 
  4875.            symbols', GDB includes all the symbols for which it has already 
  4876.            collected full details: that is, filename reflects symbols for only 
  4877.            those files whose symbols GDB has read.  You can use the command 
  4878.            info sources to find out which files these are.  If you use `maint 
  4879.            print psymbols' instead, the dump shows information about symbols 
  4880.            that GDB only knows partially---that is, symbols defined in files 
  4881.            that GDB has skimmed, but not yet read completely.  Finally, `maint 
  4882.            print msymbols' dumps just the minimal symbol information required 
  4883.            for each object file from which GDB has read some symbols. See 
  4884.            Commands to specify files, for a discussion of how GDB reads symbols 
  4885.            (in the description of symbol-file). 
  4886.  
  4887.  
  4888. ΓòÉΓòÉΓòÉ 14. Altering Execution ΓòÉΓòÉΓòÉ
  4889.  
  4890. Once you think you have found an error in your program, you might want to find 
  4891. out for certain whether correcting the apparent error would lead to correct 
  4892. results in the rest of the run.  You can find the answer by experiment, using 
  4893. the GDB features for altering execution of the program. 
  4894.  
  4895. For example, you can store new values into variables or memory locations, give 
  4896. your program a signal, restart it at a different address, or even return 
  4897. prematurely from a function. 
  4898.  
  4899.  Assignment                              Assignment to variables 
  4900.  Jumping                                 Continuing at a different address 
  4901.  
  4902.  Signaling                               Giving your program a signal 
  4903.  
  4904.  Returning                               Returning from a function 
  4905.  Calling                                 Calling your program's functions 
  4906.  Patching                                Patching your program 
  4907.  
  4908.  
  4909. ΓòÉΓòÉΓòÉ 14.1. Assignment to variables ΓòÉΓòÉΓòÉ
  4910.  
  4911. To alter the value of a variable, evaluate an assignment expression. See 
  4912. Expressions.  For example, 
  4913.  
  4914. print x=4
  4915.  
  4916. stores the value 4 into the variable x, and then prints the value of the 
  4917. assignment expression (which is 4). See Using GDB with Different Languages, for 
  4918. more information on operators in supported languages. 
  4919.  
  4920. If you are not interested in seeing the value of the assignment, use the set 
  4921. command instead of the print command.  set is really the same as print except 
  4922. that the expression's value is not printed and is not put in the value history 
  4923. ( see Value history).  The expression is evaluated only for its effects. 
  4924.  
  4925. If the beginning of the argument string of the set command appears identical to 
  4926. a set subcommand, use the set variable command instead of just set.  This 
  4927. command is identical to set except for its lack of subcommands.  For example, 
  4928. if your program has a variable width, you get an error if you try to set a new 
  4929. value with just `set width=13', because GDB has the command set width: 
  4930.  
  4931. (gdb) whatis width
  4932. type = double
  4933. (gdb) p width
  4934. $4 = 13
  4935. (gdb) set width=47
  4936. Invalid syntax in expression.
  4937.  
  4938. The invalid expression, of course, is `=47'.  In order to actually set the 
  4939. program's variable width, use 
  4940.  
  4941. (gdb) set var width=47
  4942.  
  4943. GDB allows more implicit conversions in assignments than C; you can freely 
  4944. store an integer value into a pointer variable or vice versa, and you can 
  4945. convert any structure to any other structure that is the same length or 
  4946. shorter. 
  4947.  
  4948. To store values into arbitrary places in memory, use the `{...}' construct to 
  4949. generate a value of specified type at a specified address (see Expressions). 
  4950. For example, {int}0x83040 refers to memory location 0x83040 as an integer 
  4951. (which implies a certain size and representation in memory), and 
  4952.  
  4953. set {int}0x83040 = 4
  4954.  
  4955. stores the value 4 into that memory location. 
  4956.  
  4957.  
  4958. ΓòÉΓòÉΓòÉ 14.2. Continuing at a different address ΓòÉΓòÉΓòÉ
  4959.  
  4960. Ordinarily, when you continue your program, you do so at the place where it 
  4961. stopped, with the continue command.  You can instead continue at an address of 
  4962. your own choosing, with the following commands: 
  4963.  
  4964.  jump linespec 
  4965.            Resume execution at line linespec.  Execution stops again 
  4966.            immediately if there is a breakpoint there. See Printing source 
  4967.            lines, for a description of the different forms of linespec. 
  4968.  
  4969.            The jump command does not change the current stack frame, or the 
  4970.            stack pointer, or the contents of any memory location or any 
  4971.            register other than the program counter.  If line linespec is in a 
  4972.            different function from the one currently executing, the results may 
  4973.            be bizarre if the two functions expect different patterns of 
  4974.            arguments or of local variables.  For this reason, the jump command 
  4975.            requests confirmation if the specified line is not in the function 
  4976.            currently executing.  However, even bizarre results are predictable 
  4977.            if you are well acquainted with the machine-language code of your 
  4978.            program. 
  4979.  
  4980.  jump *address 
  4981.            Resume execution at the instruction at address address. 
  4982.  
  4983.  You can get much the same effect as the jump command by storing a new value 
  4984.  into the register $pc.  The difference is that this does not start your 
  4985.  program running; it only changes the address of where it will run when you 
  4986.  continue.  For example, 
  4987.  
  4988.   set $pc = 0x485
  4989.  
  4990.  makes the next continue command or stepping command execute at address 0x485, 
  4991.  rather than at the address where your program stopped. See Continuing and 
  4992.  stepping. 
  4993.  
  4994.  The most common occasion to use the jump command is to back up-- perhaps with 
  4995.  more breakpoints set--over a portion of a program that has already executed, 
  4996.  in order to examine its execution in more detail. 
  4997.  
  4998.  
  4999. ΓòÉΓòÉΓòÉ 14.3. Giving your program a signal ΓòÉΓòÉΓòÉ
  5000.  
  5001.  signal signal 
  5002.            Resume execution where your program stopped, but immediately give it 
  5003.            the signal signal.  signal can be the name or the number of a 
  5004.            signal.  For example, on many systems signal 2 and signal SIGINT are 
  5005.            both ways of sending an interrupt signal. 
  5006.  
  5007.            Alternatively, if signal is zero, continue execution without giving 
  5008.            a signal.  This is useful when your program stopped on account of a 
  5009.            signal and would ordinary see the signal when resumed with the 
  5010.            continue command; `signal 0' causes it to resume without a signal. 
  5011.  
  5012.            signal does not repeat when you press RET a second time after 
  5013.            executing the command. 
  5014.  
  5015.  Invoking the signal command is not the same as invoking the kill utility from 
  5016.  the shell.  Sending a signal with kill causes GDB to decide what to do with 
  5017.  the signal depending on the signal handling tables (see Signals).  The signal 
  5018.  command passes the signal directly to your program. 
  5019.  
  5020.  
  5021. ΓòÉΓòÉΓòÉ 14.4. Returning from a function ΓòÉΓòÉΓòÉ
  5022.  
  5023.  return 
  5024.  return expression 
  5025.            You can cancel execution of a function call with the return command. 
  5026.            If you give an expression argument, its value is used as the 
  5027.            function's return value. 
  5028.  
  5029.  When you use return, GDB discards the selected stack frame (and all frames 
  5030.  within it).  You can think of this as making the discarded frame return 
  5031.  prematurely.  If you wish to specify a value to be returned, give that value 
  5032.  as the argument to return. 
  5033.  
  5034.  This pops the selected stack frame ( see Selecting a frame), and any other 
  5035.  frames inside of it, leaving its caller as the innermost remaining frame. 
  5036.  That frame becomes selected.  The specified value is stored in the registers 
  5037.  used for returning values of functions. 
  5038.  
  5039.  The return command does not resume execution; it leaves the program stopped in 
  5040.  the state that would exist if the function had just returned.  In contrast, 
  5041.  the finish command ( see Continuing and stepping) resumes execution until the 
  5042.  selected stack frame returns naturally. 
  5043.  
  5044.  
  5045. ΓòÉΓòÉΓòÉ 14.5. Calling program functions ΓòÉΓòÉΓòÉ
  5046.  
  5047.  call expr 
  5048.            Evaluate the expression expr without displaying void returned 
  5049.            values. 
  5050.  
  5051.  You can use this variant of the print command if you want to execute a 
  5052.  function from your program, but without cluttering the output with void 
  5053.  returned values.  If the result is not void, it is printed and saved in the 
  5054.  value history. 
  5055.  
  5056.  A new user-controlled variable, call_scratch_address, specifies the location 
  5057.  of a scratch area to be used when GDB calls a function in the target.  This is 
  5058.  necessary because the usual method of putting the scratch area on the stack 
  5059.  does not work in systems that have separate instruction and data spaces. 
  5060.  
  5061.  
  5062. ΓòÉΓòÉΓòÉ 14.6. Patching programs ΓòÉΓòÉΓòÉ
  5063.  
  5064. By default, GDB opens the file containing your program's executable code (or 
  5065. the corefile) read-only.  This prevents accidental alterations to machine code; 
  5066. but it also prevents you from intentionally patching your program's binary. 
  5067.  
  5068. If you'd like to be able to patch the binary, you can specify that explicitly 
  5069. with the set write command.  For example, you might want to turn on internal 
  5070. debugging flags, or even to make emergency repairs. 
  5071.  
  5072.  set write on 
  5073.  set write off 
  5074.            If you specify `set write on', GDB opens executable and core files 
  5075.            for both reading and writing; if you specify `set write off' (the 
  5076.            default), GDB opens them read-only. 
  5077.  
  5078.            If you have already loaded a file, you must load it again (using the 
  5079.            exec-file or core-file command) after changing set write, for your 
  5080.            new setting to take effect. 
  5081.  
  5082.  show write 
  5083.            Display whether executable files and core files are opened for 
  5084.            writing as well as reading. 
  5085.  
  5086.  
  5087. ΓòÉΓòÉΓòÉ 15. GDB Files ΓòÉΓòÉΓòÉ
  5088.  
  5089. GDB needs to know the file name of the program to be debugged, both in order to 
  5090. read its symbol table and in order to start your program. To debug a core dump 
  5091. of a previous run, you must also tell GDB the name of the core dump file. 
  5092.  
  5093.  Files                                   Commands to specify files 
  5094.  Symbol Errors                           Errors reading symbol files 
  5095.  
  5096.  
  5097. ΓòÉΓòÉΓòÉ 15.1. Commands to specify files ΓòÉΓòÉΓòÉ
  5098.  
  5099. You may want to specify executable and core dump file names. The usual way to 
  5100. do this is at start-up time, using the arguments to GDB's start-up commands ( 
  5101. see Getting In and Out of GDB). 
  5102.  
  5103. Occasionally it is necessary to change to a different file during a GDB 
  5104. session.  Or you may run GDB and forget to specify a file you want to use.  In 
  5105. these situations the GDB commands to specify new files are useful. 
  5106.  
  5107.  file filename 
  5108.            Use filename as the program to be debugged.  It is read for its 
  5109.            symbols and for the contents of pure memory.  It is also the program 
  5110.            executed when you use the run command.  If you do not specify a 
  5111.            directory and the file is not found in the GDB working directory, 
  5112.            GDB uses the environment variable PATH as a list of directories to 
  5113.            search, just as the shell does when looking for a program to run. 
  5114.            You can change the value of this variable, for both GDB and your 
  5115.            program, using the path command. 
  5116.  
  5117.            On systems with memory-mapped files, an auxiliary file 
  5118.            `filename.syms' may hold symbol table information for filename.  If 
  5119.            so, GDB maps in the symbol table from `filename.syms', starting up 
  5120.            more quickly.  See the descriptions of the file options `-mapped' 
  5121.            and `-readnow' (available on the command line, and with the commands 
  5122.            file, symbol-file, or add-symbol-file, described below), for more 
  5123.            information. 
  5124.  
  5125.  file 
  5126.            file with no argument makes GDB discard any information it has on 
  5127.            both executable file and the symbol table. 
  5128.  
  5129.  exec-file [ filename ] 
  5130.            Specify that the program to be run (but not the symbol table) is 
  5131.            found in filename.  GDB searches the environment variable PATH if 
  5132.            necessary to locate your program.  Omitting filename means to 
  5133.            discard information on the executable file. 
  5134.  
  5135.  symbol-file [ filename ] 
  5136.            Read symbol table information from file filename.  PATH is searched 
  5137.            when necessary.  Use the file command to get both symbol table and 
  5138.            program to run from the same file. 
  5139.  
  5140.            symbol-file with no argument clears out GDB information on your 
  5141.            program's symbol table. 
  5142.  
  5143.            The symbol-file command causes GDB to forget the contents of its 
  5144.            convenience variables, the value history, and all breakpoints and 
  5145.            auto-display expressions.  This is because they may contain pointers 
  5146.            to the internal data recording symbols and data types, which are 
  5147.            part of the old symbol table data being discarded inside GDB. 
  5148.  
  5149.            symbol-file does not repeat if you press RET again after executing 
  5150.            it once. 
  5151.  
  5152.            When GDB is configured for a particular environment, it understands 
  5153.            debugging information in whatever format is the standard generated 
  5154.            for that environment; you may use either a gnu compiler, or other 
  5155.            compilers that adhere to the local conventions.  Best results are 
  5156.            usually obtained from gnu compilers; for example, using gcc you can 
  5157.            generate debugging information for optimized code. 
  5158.  
  5159.            On some kinds of object files, the symbol-file command does not 
  5160.            normally read the symbol table in full right away.  Instead, it 
  5161.            scans the symbol table quickly to find which source files and which 
  5162.            symbols are present.  The details are read later, one source file at 
  5163.            a time, as they are needed. 
  5164.  
  5165.            The purpose of this two-stage reading strategy is to make GDB start 
  5166.            up faster.  For the most part, it is invisible except for occasional 
  5167.            pauses while the symbol table details for a particular source file 
  5168.            are being read.  (The set verbose command can turn these pauses into 
  5169.            messages if desired. See Optional warnings and messages.) 
  5170.  
  5171.            We have not implemented the two-stage strategy for COFF yet.  When 
  5172.            the symbol table is stored in COFF format, symbol-file reads the 
  5173.            symbol table data in full right away. 
  5174.  
  5175.  symbol-file filename [ -readnow ] [ -mapped ] 
  5176.  file filename [ -readnow ] [ -mapped ] 
  5177.            You can override the GDB two-stage strategy for reading symbol 
  5178.            tables by using the `-readnow' option with any of the commands that 
  5179.            load symbol table information, if you want to be sure GDB has the 
  5180.            entire symbol table available. 
  5181.  
  5182.            If memory-mapped files are available on your system through the mmap 
  5183.            system call, you can use another option, `-mapped', to cause GDB to 
  5184.            write the symbols for your program into a reusable file.  Future GDB 
  5185.            debugging sessions map in symbol information from this auxiliary 
  5186.            symbol file (if the program has not changed), rather than spending 
  5187.            time reading the symbol table from the executable program.  Using 
  5188.            the `-mapped' option has the same effect as starting GDB with the 
  5189.            `-mapped' command-line option. 
  5190.  
  5191.            You can use both options together, to make sure the auxiliary symbol 
  5192.            file has all the symbol information for your program. 
  5193.  
  5194.            The auxiliary symbol file for a program called myprog is called 
  5195.            `myprog.syms'.  Once this file exists (so long as it is newer than 
  5196.            the corresponding executable), GDB always attempts to use it when 
  5197.            you debug myprog; no special options or commands are needed. 
  5198.  
  5199.            The `.syms' file is specific to the host machine where you run GDB. 
  5200.            It holds an exact image of the internal GDB symbol table.  It cannot 
  5201.            be shared across multiple host platforms. 
  5202.  
  5203.  core-file [ filename ] 
  5204.            Specify the whereabouts of a core dump file to be used as the 
  5205.            ``contents of memory''.  Traditionally, core files contain only some 
  5206.            parts of the address space of the process that generated them; GDB 
  5207.            can access the executable file itself for other parts. 
  5208.  
  5209.            core-file with no argument specifies that no core file is to be 
  5210.            used. 
  5211.  
  5212.            Note that the core file is ignored when your program is actually 
  5213.            running under GDB.  So, if you have been running your program and 
  5214.            you wish to debug a core file instead, you must kill the subprocess 
  5215.            in which the program is running.  To do this, use the kill command 
  5216.            (see Killing the child process). 
  5217.  
  5218.  load filename 
  5219.            Depending on what remote debugging facilities are configured into 
  5220.            GDB, the load command may be available.  Where it exists, it is 
  5221.            meant to make filename (an executable) available for debugging on 
  5222.            the remote system---by downloading, or dynamic linking, for example. 
  5223.            load also records the filename symbol table in GDB, like the 
  5224.            add-symbol-file command. 
  5225.  
  5226.            If your GDB does not have a load command, attempting to execute it 
  5227.            gets the error message ``You can't do that when your target is ...'' 
  5228.  
  5229.            The file is loaded at whatever address is specified in the 
  5230.            executable. For some object file formats, you can specify the load 
  5231.            address when you link the program; for other formats, like a.out, 
  5232.            the object file format specifies a fixed address. 
  5233.  
  5234.            On VxWorks, load links filename dynamically on the current target 
  5235.            system as well as adding its symbols in GDB. 
  5236.  
  5237.            With the Nindy interface to an Intel 960 board, load downloads 
  5238.            filename to the 960 as well as adding its symbols in GDB. load does 
  5239.            not repeat if you press RET again after using it. 
  5240.  
  5241.  add-symbol-file filename address 
  5242.  add-symbol-file filename address [ -readnow ] [ -mapped ] 
  5243.            The add-symbol-file command reads additional symbol table 
  5244.            information from the file filename.  You would use this command when 
  5245.            filename has been dynamically loaded (by some other means) into the 
  5246.            program that is running.  address should be the memory address at 
  5247.            which the file has been loaded; GDB cannot figure this out for 
  5248.            itself. You can specify address as an expression. 
  5249.  
  5250.            The symbol table of the file filename is added to the symbol table 
  5251.            originally read with the symbol-file command.  You can use the 
  5252.            add-symbol-file command any number of times; the new symbol data 
  5253.            thus read keeps adding to the old.  To discard all old symbol data 
  5254.            instead, use the symbol-file command. 
  5255.  
  5256.            add-symbol-file does not repeat if you press RET after using it. 
  5257.  
  5258.            You can use the `-mapped' and `-readnow' options just as with the 
  5259.            symbol-file command, to change how GDB manages the symbol table 
  5260.            information for filename. 
  5261.  
  5262.  add-shared-symbol-file 
  5263.            The add-shared-symbol-file command can be used only under Harris' 
  5264.            CXUX operating system for the Motorola 88k.  GDB automatically looks 
  5265.            for shared libraries, however if GDB does not find yours, you can 
  5266.            run add-shared-symbol-file.  It takes no arguments. 
  5267.  
  5268.  section 
  5269.            The section command changes the base address of section SECTION of 
  5270.            the exec file to ADDR.  This can be used if the exec file does not 
  5271.            contain section addresses, (such as in the a.out format), or when 
  5272.            the addresses specified in the file itself are wrong.  Each section 
  5273.            must be changed separately.  The ``info files'' command lists all 
  5274.            the sections and their addresses. 
  5275.  
  5276.  info files 
  5277.  info target 
  5278.            info files and info target are synonymous; both print the current 
  5279.            target (see Specifying a Debugging Target), including the names of 
  5280.            the executable and core dump files currently in use by GDB, and the 
  5281.            files from which symbols were loaded.  The command help target lists 
  5282.            all possible targets rather than current ones. 
  5283.  
  5284.  All file-specifying commands allow both absolute and relative file names as 
  5285.  arguments.  GDB always converts the file name to an absolute file name and 
  5286.  remembers it that way. 
  5287.  
  5288.  GDB supports SunOS, SVr4, Irix 5, and IBM RS/6000 shared libraries. GDB 
  5289.  automatically loads symbol definitions from shared libraries when you use the 
  5290.  run command, or when you examine a core file. (Before you issue the run 
  5291.  command, GDB does not understand references to a function in a shared library, 
  5292.  however---unless you are debugging a core file). 
  5293.  
  5294.  info share 
  5295.  info sharedlibrary 
  5296.            Print the names of the shared libraries which are currently loaded. 
  5297.  
  5298.  sharedlibrary regex 
  5299.  share regex 
  5300.            Load shared object library symbols for files matching a Unix regular 
  5301.            expression. As with files loaded automatically, it only loads shared 
  5302.            libraries required by your program for a core file or after typing 
  5303.            run.  If regex is omitted all shared libraries required by your 
  5304.            program are loaded. 
  5305.  
  5306.  
  5307. ΓòÉΓòÉΓòÉ 15.2. Errors reading symbol files ΓòÉΓòÉΓòÉ
  5308.  
  5309. While reading a symbol file, GDB occasionally encounters problems, such as 
  5310. symbol types it does not recognize, or known bugs in compiler output.  By 
  5311. default, GDB does not notify you of such problems, since they are relatively 
  5312. common and primarily of interest to people debugging compilers.  If you are 
  5313. interested in seeing information about ill-constructed symbol tables, you can 
  5314. either ask GDB to print only one message about each such type of problem, no 
  5315. matter how many times the problem occurs; or you can ask GDB to print more 
  5316. messages, to see how many times the problems occur, with the set complaints 
  5317. command ( see Optional warnings and messages). 
  5318.  
  5319. The messages currently printed, and their meanings, include: 
  5320.  
  5321.  inner block not inside outer block in symbol 
  5322.            The symbol information shows where symbol scopes begin and end (such 
  5323.            as at the start of a function or a block of statements).  This error 
  5324.            indicates that an inner scope block is not fully contained in its 
  5325.            outer scope blocks. 
  5326.  
  5327.            GDB circumvents the problem by treating the inner block as if it had 
  5328.            the same scope as the outer block.  In the error message, symbol may 
  5329.            be shown as ``(don't know)'' if the outer block is not a function. 
  5330.  
  5331.  block at address out of order 
  5332.            The symbol information for symbol scope blocks should occur in order 
  5333.            of increasing addresses.  This error indicates that it does not do 
  5334.            so. 
  5335.  
  5336.            GDB does not circumvent this problem, and has trouble locating 
  5337.            symbols in the source file whose symbols it is reading.  (You can 
  5338.            often determine what source file is affected by specifying set 
  5339.            verbose on. See Optional warnings and messages.) 
  5340.  
  5341.  bad block start address patched 
  5342.            The symbol information for a symbol scope block has a start address 
  5343.            smaller than the address of the preceding source line.  This is 
  5344.            known to occur in the SunOS 4.1.1 (and earlier) C compiler. 
  5345.  
  5346.            GDB circumvents the problem by treating the symbol scope block as 
  5347.            starting on the previous source line. 
  5348.  
  5349.  bad string table offset in symbol n 
  5350.            Symbol number n contains a pointer into the string table which is 
  5351.            larger than the size of the string table. 
  5352.  
  5353.            GDB circumvents the problem by considering the symbol to have the 
  5354.            name foo, which may cause other problems if many symbols end up with 
  5355.            this name. 
  5356.  
  5357.  unknown symbol type 0xnn 
  5358.            The symbol information contains new data types that GDB does not yet 
  5359.            know how to read.  0xnn is the symbol type of the misunderstood 
  5360.            information, in hexadecimal. 
  5361.  
  5362.            GDB circumvents the error by ignoring this symbol information.  This 
  5363.            usually allows you to debug your program, though certain symbols are 
  5364.            not accessible.  If you encounter such a problem and feel like 
  5365.            debugging it, you can debug gdb with itself, breakpoint on complain, 
  5366.            then go up to the function read_dbx_symtab and examine *bufp to see 
  5367.            the symbol. 
  5368.  
  5369.  stub type has NULL name 
  5370.            GDB could not find the full definition for a struct or class. 
  5371.  
  5372.  const/volatile indicator missing (ok if using g++ v1.x), got... 
  5373.            The symbol information for a C++ member function is missing some 
  5374.            information that recent versions of the compiler should have output 
  5375.            for it. 
  5376.  
  5377.  info mismatch between compiler and debugger 
  5378.            GDB could not parse a type specification output by the compiler. 
  5379.  
  5380.  
  5381. ΓòÉΓòÉΓòÉ 16. Specifying a Debugging Target ΓòÉΓòÉΓòÉ
  5382.  
  5383. A target is the execution environment occupied by your program. Often, GDB runs 
  5384. in the same host environment as your program; in that case, the debugging 
  5385. target is specified as a side effect when you use the file or core commands. 
  5386. When you need more flexibility---for example, running GDB on a physically 
  5387. separate host, or controlling a standalone system over a serial port or a 
  5388. realtime system over a TCP/IP connection---you can use the target command to 
  5389. specify one of the target types configured for GDB ( see Commands for managing 
  5390. targets). 
  5391.  
  5392.  Active Targets                          Active targets 
  5393.  Target Commands                         Commands for managing targets 
  5394.  Remote                                  Remote debugging 
  5395.  
  5396.  
  5397. ΓòÉΓòÉΓòÉ 16.1. Active targets ΓòÉΓòÉΓòÉ
  5398.  
  5399. There are three classes of targets: processes, core files, and executable 
  5400. files.  GDB can work concurrently on up to three active targets, one in each 
  5401. class.  This allows you to (for example) start a process and inspect its 
  5402. activity without abandoning your work on a core file. 
  5403.  
  5404. For example, if you execute `gdb a.out', then the executable file a.out is the 
  5405. only active target.  If you designate a core file as well---presumably from a 
  5406. prior run that crashed and coredumped---then GDB has two active targets and 
  5407. uses them in tandem, looking first in the corefile target, then in the 
  5408. executable file, to satisfy requests for memory addresses.  (Typically, these 
  5409. two classes of target are complementary, since core files contain only a 
  5410. program's read-write memory---variables and so on---plus machine status, while 
  5411. executable files contain only the program text and initialized data.) 
  5412.  
  5413. When you type run, your executable file becomes an active process target as 
  5414. well.  When a process target is active, all GDB commands requesting memory 
  5415. addresses refer to that target; addresses in an active core file or executable 
  5416. file target are obscured while the process target is active. 
  5417.  
  5418. Use the core-file and exec-file commands to select a new core file or 
  5419. executable target ( see Commands to specify files).  To specify as a target a 
  5420. process that is already running, use the attach command ( see Debugging an 
  5421. already-running process). 
  5422.  
  5423.  
  5424. ΓòÉΓòÉΓòÉ 16.2. Commands for managing targets ΓòÉΓòÉΓòÉ
  5425.  
  5426.  target type parameters 
  5427.            Connects the GDB host environment to a target machine or process.  A 
  5428.            target is typically a protocol for talking to debugging facilities. 
  5429.            You use the argument type to specify the type or protocol of the 
  5430.            target machine. 
  5431.  
  5432.            Further parameters are interpreted by the target protocol, but 
  5433.            typically include things like device names or host names to connect 
  5434.            with, process numbers, and baud rates. 
  5435.  
  5436.            The target command does not repeat if you press RET again after 
  5437.            executing the command. 
  5438.  
  5439.  help target 
  5440.            Displays the names of all targets available.  To display targets 
  5441.            currently selected, use either info target or info files (see 
  5442.            Commands to specify files). 
  5443.  
  5444.  help target name 
  5445.            Describe a particular target, including any parameters necessary to 
  5446.            select it. 
  5447.  
  5448.  set gnutarget args 
  5449.            GDBuses its own library BFD to read your files.  GDB knows whether 
  5450.            it is reading an executable, a core, or a .o file, however you can 
  5451.            specify the file format with the set gnutarget command.  Unlike most 
  5452.            target commands, with gnutarget the target refers to a program, not 
  5453.            a machine. 
  5454.  
  5455.            Warning: To specify a file format with set gnutarget, you must know 
  5456.            the actual BFD name. 
  5457.  
  5458.            See Commands to specify files. 
  5459.  
  5460.  show gnutarget 
  5461.            Use the show gnutarget command to display what file format gnutarget 
  5462.            is set to read.  If you have not set gnutarget, GDB will determine 
  5463.            the file format for each file automatically and show gnutarget 
  5464.            displays The current BDF target is "auto". 
  5465.  
  5466.  Here are some common targets (available, or not, depending on the GDB 
  5467.  configuration): 
  5468.  
  5469.  target exec program 
  5470.            An executable file.  `target exec program' is the same as `exec-file 
  5471.            program'. 
  5472.  
  5473.  target core filename 
  5474.            A core dump file.  `target core filename' is the same as `core-file 
  5475.            filename'. 
  5476.  
  5477.  target remote dev 
  5478.            Remote serial target in GDB-specific protocol.  The argument dev 
  5479.            specifies what serial device to use for the connection (e.g. 
  5480.            `/dev/ttya'). See Remote debugging.  target remote now supports the 
  5481.            load command.  This is only useful if you have some other way of 
  5482.            getting the stub to the target system, and you can put it somewhere 
  5483.            in memory where it won't get clobbered by the download. 
  5484.  
  5485.  target sim 
  5486.            CPU simulator.  See Simulated CPU Target. 
  5487.  
  5488.  target udi keyword 
  5489.            Remote AMD29K target, using the AMD UDI protocol.  The keyword 
  5490.            argument specifies which 29K board or simulator to use. See The UDI 
  5491.            protocol for AMD29K. 
  5492.  
  5493.  target amd-eb dev speed PROG 
  5494.            Remote PC-resident AMD EB29K board, attached over serial lines. dev 
  5495.            is the serial device, as for target remote; speed allows you to 
  5496.            specify the linespeed; and PROG is the name of the program to be 
  5497.            debugged, as it appears to DOS on the PC. See The EBMON protocol for 
  5498.            AMD29K. 
  5499.  
  5500.  target nindy devicename 
  5501.            An Intel 960 board controlled by a Nindy Monitor.  devicename is the 
  5502.            name of the serial device to use for the connection, e.g. 
  5503.            `/dev/ttya'.  See GDB with a remote i960 (Nindy). 
  5504.  
  5505.  target st2000 dev speed 
  5506.            A Tandem ST2000 phone switch, running Tandem's STDBUG protocol.  dev 
  5507.            is the name of the device attached to the ST2000 serial line; speed 
  5508.            is the communication line speed.  The arguments are not used if GDB 
  5509.            is configured to connect to the ST2000 using TCP or Telnet. See GDB 
  5510.            with a Tandem ST2000. 
  5511.  
  5512.  target vxworks machinename 
  5513.            A VxWorks system, attached via TCP/IP.  The argument machinename is 
  5514.            the target system's machine name or IP address. See GDB and VxWorks. 
  5515.  
  5516.  target cpu32bug dev 
  5517.            CPU32BUG monitor, running on a CPU32 (M68K) board. 
  5518.  
  5519.  target op50n dev 
  5520.            OP50N monitor, running on an OKI HPPA board. 
  5521.  
  5522.  target w89k dev 
  5523.            W89K monitor, running on a Winbond HPPA board. 
  5524.  
  5525.  target est dev 
  5526.            EST-300 ICE monitor, running on a CPU32 (M68K) board. 
  5527.  
  5528.  target rom68k dev 
  5529.            ROM 68K monitor, running on an IDP board. 
  5530.  
  5531.  target array dev 
  5532.            Array Tech LSI33K RAID controller board. 
  5533.  
  5534.  target sparclite dev 
  5535.            Fujitsu sparclite boards, used only for the purpose of loading. You 
  5536.            must use an additional command to debug the program. For example: 
  5537.            target remote dev using GDB standard remote protocol. 
  5538.  
  5539.  Different targets are available on different configurations of GDB; your 
  5540.  configuration may have more or fewer targets. 
  5541.  
  5542.  
  5543. ΓòÉΓòÉΓòÉ 16.3. Choosing target byte order ΓòÉΓòÉΓòÉ
  5544.  
  5545. You can now choose which byte order to use with a target system. Use the set 
  5546. endian big and set endian little commands. Use the set endian auto command to 
  5547. instruct GDB to use the byte order associated with the executable. You can see 
  5548. the current setting for byte order with the show endian command. 
  5549.  
  5550. Warning: Currently, only embedded MIPS configurations support dynamic selection 
  5551. of target byte order. 
  5552.  
  5553.  
  5554. ΓòÉΓòÉΓòÉ 16.4. Remote debugging ΓòÉΓòÉΓòÉ
  5555.  
  5556. If you are trying to debug a program running on a machine that cannot run GDB 
  5557. in the usual way, it is often useful to use remote debugging. For example, you 
  5558. might use remote debugging on an operating system kernel, or on a small system 
  5559. which does not have a general purpose operating system powerful enough to run a 
  5560. full-featured debugger. 
  5561.  
  5562. Some configurations of GDB have special serial or TCP/IP interfaces to make 
  5563. this work with particular debugging targets.  In addition, GDB comes with a 
  5564. generic serial protocol (specific to GDB, but not specific to any particular 
  5565. target system) which you can use if you write the remote stubs---the code that 
  5566. runs on the remote system to communicate with GDB. 
  5567.  
  5568. Other remote targets may be available in your configuration of GDB; use help 
  5569. target to list them. 
  5570.  
  5571.  Remote Serial                           GDBN remote serial protocol 
  5572.  
  5573.  i960-Nindy Remote                       GDBN with a remote i960 (Nindy) 
  5574.  
  5575.  UDI29K Remote                           The UDI protocol for AMD29K 
  5576.  EB29K Remote                            The EBMON protocol for AMD29K 
  5577.  
  5578.  VxWorks Remote                          GDBN and VxWorks 
  5579.  
  5580.  ST2000 Remote                           GDBN with a Tandem ST2000 
  5581.  
  5582.  Hitachi Remote                          GDBN and Hitachi Microprocessors 
  5583.  
  5584.  MIPS Remote                             GDBN and MIPS boards 
  5585.  
  5586.  Simulator                               Simulated CPU target 
  5587.  
  5588.  
  5589. ΓòÉΓòÉΓòÉ 16.4.1. The GDB remote serial protocol ΓòÉΓòÉΓòÉ
  5590.  
  5591. To debug a program running on another machine (the debugging target machine), 
  5592. you must first arrange for all the usual prerequisites for the program to run 
  5593. by itself.  For example, for a C program, you need: 
  5594.  
  5595.    1. A startup routine to set up the C runtime environment; these usually have 
  5596.       a name like `crt0'.  The startup routine may be supplied by your hardware 
  5597.       supplier, or you may have to write your own. 
  5598.  
  5599.    2. You probably need a C subroutine library to support your program's 
  5600.       subroutine calls, notably managing input and output. 
  5601.  
  5602.    3. A way of getting your program to the other machine---for example, a 
  5603.       download program.  These are often supplied by the hardware manufacturer, 
  5604.       but you may have to write your own from hardware documentation. 
  5605.  
  5606.  The next step is to arrange for your program to use a serial port to 
  5607.  communicate with the machine where GDB is running (the host machine).  In 
  5608.  general terms, the scheme looks like this: 
  5609.  
  5610.  On the host, 
  5611.            GDB already understands how to use this protocol; when everything 
  5612.            else is set up, you can simply use the `target remote' command (see 
  5613.            Specifying a Debugging Target). 
  5614.  
  5615.  On the target, 
  5616.            you must link with your program a few special-purpose subroutines 
  5617.            that implement the GDB remote serial protocol.  The file containing 
  5618.            these subroutines is called  a debugging stub. 
  5619.  
  5620.            On certain remote targets, you can use an auxiliary program 
  5621.            gdbserver instead of linking a stub into your program. See Using the 
  5622.            gdbserver program, for details. 
  5623.  
  5624.  The debugging stub is specific to the architecture of the remote machine; for 
  5625.  example, use `sparc-stub.c' to debug programs on sparc boards. 
  5626.  
  5627.  These working remote stubs are distributed with GDB: 
  5628.  
  5629.  sparc-stub.c 
  5630.            For sparc architectures. 
  5631.  
  5632.  m68k-stub.c 
  5633.            For Motorola 680x0 architectures. 
  5634.  
  5635.  i386-stub.c 
  5636.            For Intel 386 and compatible architectures. 
  5637.  
  5638.  The `README' file in the GDB distribution may list other recently added stubs. 
  5639.  
  5640.  Stub Contents                           What the stub can do for you 
  5641.  Bootstrapping                           What you must do for the stub 
  5642.  Debug Session                           Putting it all together 
  5643.  Protocol                                Outline of the communication protocol 
  5644.  
  5645.  Server                                  Using the `gdbserver' program 
  5646.  
  5647.  NetWare                                 Using the `gdbserve.nlm' program 
  5648.  
  5649.  
  5650. ΓòÉΓòÉΓòÉ 16.4.1.1. What the stub can do for you ΓòÉΓòÉΓòÉ
  5651.  
  5652. The debugging stub for your architecture supplies these three subroutines: 
  5653.  
  5654.  set_debug_traps 
  5655.            This routine arranges for handle_exception to run when your program 
  5656.            stops.  You must call this subroutine explicitly near the beginning 
  5657.            of your program. 
  5658.  
  5659.  handle_exception 
  5660.            This is the central workhorse, but your program never calls it 
  5661.            explicitly---the setup code arranges for handle_exception to run 
  5662.            when a trap is triggered. 
  5663.  
  5664.            handle_exception takes control when your program stops during 
  5665.            execution (for example, on a breakpoint), and mediates 
  5666.            communications with GDB on the host machine.  This is where the 
  5667.            communications protocol is implemented; handle_exception acts as the 
  5668.            GDB representative on the target machine; it begins by sending 
  5669.            summary information on the state of your program, then continues to 
  5670.            execute, retrieving and transmitting any information GDB needs, 
  5671.            until you execute a GDB command that makes your program resume; at 
  5672.            that point, handle_exception returns control to your own code on the 
  5673.            target machine. 
  5674.  
  5675.  breakpoint 
  5676.            Use this auxiliary subroutine to make your program contain a 
  5677.            breakpoint.  Depending on the particular situation, this may be the 
  5678.            only way for GDB to get control.  For instance, if your target 
  5679.            machine has some sort of interrupt button, you won't need to call 
  5680.            this; pressing the interrupt button transfers control to 
  5681.            handle_exception---in effect, to GDB.  On some machines, simply 
  5682.            receiving characters on the serial port may also trigger a trap; 
  5683.            again, in that situation, you don't need to call breakpoint from 
  5684.            your own program---simply running `target remote' from the host GDB 
  5685.            session gets control. 
  5686.  
  5687.            Call breakpoint if none of these is true, or if you simply want to 
  5688.            make certain your program stops at a predetermined point for the 
  5689.            start of your debugging session. 
  5690.  
  5691.  
  5692. ΓòÉΓòÉΓòÉ 16.4.1.2. What you must do for the stub ΓòÉΓòÉΓòÉ
  5693.  
  5694. The debugging stubs that come with GDB are set up for a particular chip 
  5695. architecture, but they have no information about the rest of your debugging 
  5696. target machine. 
  5697.  
  5698. First of all you need to tell the stub how to communicate with the serial port. 
  5699.  
  5700.  int getDebugChar() 
  5701.            Write this subroutine to read a single character from the serial 
  5702.            port. It may be identical to getchar for your target system; a 
  5703.            different name is used to allow you to distinguish the two if you 
  5704.            wish. 
  5705.  
  5706.  void putDebugChar(int) 
  5707.            Write this subroutine to write a single character to the serial 
  5708.            port. It may be identical to putchar for your target system; a 
  5709.            different name is used to allow you to distinguish the two if you 
  5710.            wish. 
  5711.  
  5712.  If you want GDB to be able to stop your program while it is running, you need 
  5713.  to use an interrupt-driven serial driver, and arrange for it to stop when it 
  5714.  receives a ^C (`\003', the control-C character).  That is the character which 
  5715.  GDB uses to tell the remote system to stop. 
  5716.  
  5717.  Getting the debugging target to return the proper status to GDB probably 
  5718.  requires changes to the standard stub; one quick and dirty way is to just 
  5719.  execute a breakpoint instruction (the ``dirty'' part is that GDB reports a 
  5720.  SIGTRAP instead of a SIGINT). 
  5721.  
  5722.  Other routines you need to supply are: 
  5723.  
  5724.  void exceptionHandler (int exception_number, void *exception_address) 
  5725.            Write this function to install exception_address in the exception 
  5726.            handling tables.  You need to do this because the stub does not have 
  5727.            any way of knowing what the exception handling tables on your target 
  5728.            system are like (for example, the processor's table might be in rom, 
  5729.            containing entries which point to a table in ram). exception_number 
  5730.            is the exception number which should be changed; its meaning is 
  5731.            architecture-dependent (for example, different numbers might 
  5732.            represent divide by zero, misaligned access, etc).  When this 
  5733.            exception occurs, control should be transferred directly to 
  5734.            exception_address, and the processor state (stack, registers, and so 
  5735.            on) should be just as it is when a processor exception occurs.  So 
  5736.            if you want to use a jump instruction to reach exception_address, it 
  5737.            should be a simple jump, not a jump to subroutine. 
  5738.  
  5739.            For the 386, exception_address should be installed as an interrupt 
  5740.            gate so that interrupts are masked while the handler runs.  The gate 
  5741.            should be at privilege level 0 (the most privileged level).  The 
  5742.            sparc and 68k stubs are able to mask interrup themselves without 
  5743.            help from exceptionHandler. 
  5744.  
  5745.  void flush_i_cache() 
  5746.            (sparc and sparclite only) Write this subroutine to flush the 
  5747.            instruction cache, if any, on your target machine.  If there is no 
  5748.            instruction cache, this subroutine may be a no-op. 
  5749.  
  5750.            On target machines that have instruction caches, GDB requires this 
  5751.            function to make certain that the state of your program is stable. 
  5752.  
  5753.  You must also make sure this library routine is available: 
  5754.  
  5755.  void *memset(void *, int, int) 
  5756.            This is the standard library function memset that sets an area of 
  5757.            memory to a known value.  If you have one of the free versions of 
  5758.            libc.a, memset can be found there; otherwise, you must either obtain 
  5759.            it from your hardware manufacturer, or write your own. 
  5760.  
  5761.  If you do not use the GNU C compiler, you may need other standard library 
  5762.  subroutines as well; this varies from one stub to another, but in general the 
  5763.  stubs are likely to use any of the common library subroutines which gcc 
  5764.  generates as inline code. 
  5765.  
  5766.  
  5767. ΓòÉΓòÉΓòÉ 16.4.1.3. Putting it all together ΓòÉΓòÉΓòÉ
  5768.  
  5769. In summary, when your program is ready to debug, you must follow these steps. 
  5770.  
  5771.    1. Make sure you have the supporting low-level routines (see What you must 
  5772.       do for the stub): 
  5773.  
  5774.             getDebugChar, putDebugChar,
  5775.             flush_i_cache, memset, exceptionHandler.
  5776.  
  5777.    2. Insert these lines near the top of your program: 
  5778.  
  5779.             set_debug_traps();
  5780.             breakpoint();
  5781.  
  5782.    3. For the 680x0 stub only, you need to provide a variable called 
  5783.       exceptionHook.  Normally you just use: 
  5784.  
  5785.             void (*exceptionHook)() = 0;
  5786.  
  5787.       but if before calling set_debug_traps, you set it to point to a function 
  5788.       in your program, that function is called when GDB continues after 
  5789.       stopping on a trap (for example, bus error).  The function indicated by 
  5790.       exceptionHook is called with one parameter: an int which is the exception 
  5791.       number. 
  5792.  
  5793.    4. Compile and link together: your program, the GDB debugging stub for your 
  5794.       target architecture, and the supporting subroutines. 
  5795.  
  5796.    5. Make sure you have a serial connection between your target machine and 
  5797.       the GDB host, and identify the serial port on the host. 
  5798.  
  5799.    6. Download your program to your target machine (or get it there by whatever 
  5800.       means the manufacturer provides), and start it. 
  5801.  
  5802.    7. To start remote debugging, run GDB on the host machine, and specify as an 
  5803.       executable file the program that is running in the remote machine. This 
  5804.       tells GDB how to find your program's symbols and the contents of its pure 
  5805.       text. 
  5806.  
  5807.       Then establish communication using the target remote command. Its 
  5808.       argument specifies how to communicate with the target machine---either 
  5809.       via a devicename attached to a direct serial line, or a TCP port (usually 
  5810.       to a terminal server which in turn has a serial line to the target).  For 
  5811.       example, to use a serial line connected to the device named `/dev/ttyb': 
  5812.  
  5813.             target remote /dev/ttyb
  5814.  
  5815.       To use a TCP connection, use an argument of the form host:port.  For 
  5816.       example, to connect to port 2828 on a terminal server named manyfarms: 
  5817.  
  5818.             target remote manyfarms:2828
  5819.  
  5820.  Now you can use all the usual commands to examine and change data and to step 
  5821.  and continue the remote program. 
  5822.  
  5823.  To resume the remote program and stop debugging it, use the detach command. 
  5824.  
  5825.  Whenever GDB is waiting for the remote program, if you type the interrupt 
  5826.  character (often C-C), GDB attempts to stop the program.  This may or may not 
  5827.  succeed, depending in part on the hardware and the serial drivers the remote 
  5828.  system uses.  If you type the interrupt character once again, GDB displays 
  5829.  this prompt: 
  5830.  
  5831.   Interrupted while waiting for the program.
  5832.   Give up (and stop debugging it)?  (y or n)
  5833.  
  5834.  If you type y, GDB abandons the remote debugging session. (If you decide you 
  5835.  want to try again later, you can use `target remote' again to connect once 
  5836.  more.)  If you type n, GDB goes back to waiting. 
  5837.  
  5838.  
  5839. ΓòÉΓòÉΓòÉ 16.4.1.4. Communication protocol ΓòÉΓòÉΓòÉ
  5840.  
  5841. The stub files provided with GDB implement the target side of the communication 
  5842. protocol, and the GDB side is implemented in the GDB source file `remote.c'. 
  5843. Normally, you can simply allow these subroutines to communicate, and ignore the 
  5844. details.  (If you're implementing your own stub file, you can still ignore the 
  5845. details: start with one of the existing stub files.  `sparc-stub.c' is the best 
  5846. organized, and therefore the easiest to read.) 
  5847.  
  5848. However, there may be occasions when you need to know something about the 
  5849. protocol---for example, if there is only one serial port to your target 
  5850. machine, you might want your program to do something special if it recognizes a 
  5851. packet meant for GDB. 
  5852.  
  5853. All GDB commands and responses (other than acknowledgements, which are single 
  5854. characters) are sent as a packet which includes a checksum.  A packet is 
  5855. introduced with the character `$', and ends with the character `#' followed by 
  5856. a two-digit checksum: 
  5857.  
  5858. $packet info#checksum
  5859.  
  5860. checksum is computed as the modulo 256 sum of the packet info characters. 
  5861.  
  5862. When either the host or the target machine receives a packet, the first 
  5863. response expected is an acknowledgement: a single character, either `+' (to 
  5864. indicate the package was received correctly) or `-' (to request 
  5865. retransmission). 
  5866.  
  5867. The host (GDB) sends commands, and the target (the debugging stub incorporated 
  5868. in your program) sends data in response.  The target also sends data when your 
  5869. program stops. 
  5870.  
  5871. Command packets are distinguished by their first character, which identifies 
  5872. the kind of command. 
  5873.  
  5874. These are some of the commands currently supported (for a complete list of 
  5875. commands, look in `gdb/remote.c.'): 
  5876.  
  5877.  g 
  5878.            Requests the values of CPU registers. 
  5879.  
  5880.  G 
  5881.            Sets the values of CPU registers. 
  5882.  
  5883.  maddr,count 
  5884.            Read count bytes at location addr. 
  5885.  
  5886.  Maddr,count:... 
  5887.            Write count bytes at location addr. 
  5888.  
  5889.  c 
  5890.  caddr 
  5891.            Resume execution at the current address (or at addr if supplied). 
  5892.  
  5893.  s 
  5894.  saddr 
  5895.            Step the target program for one instruction, from either the current 
  5896.            program counter or from addr if supplied. 
  5897.  
  5898.  k 
  5899.            Kill the target program. 
  5900.  
  5901.  ? 
  5902.            Report the most recent signal.  To allow you to take advantage of 
  5903.            the GDB signal handling commands, one of the functions of the 
  5904.            debugging stub is to report CPU traps as the corresponding POSIX 
  5905.            signal values. 
  5906.  
  5907.  T 
  5908.            Allows the remote stub to send only the registers that GDB needs to 
  5909.            make a quick decision about single-stepping or conditional 
  5910.            breakpoints. This eliminates the need to fetch the entire register 
  5911.            set for each instruction being stepped through. 
  5912.  
  5913.            The GDB remote serial protocol now implements a write-through cache 
  5914.            for registers.  GDB only re-reads the registers if the target has 
  5915.            run. 
  5916.  
  5917.  If you have trouble with the serial connection, you can use the command set 
  5918.  remotedebug.  This makes GDB report on all packets sent back and forth across 
  5919.  the serial line to the remote machine.  The packet-debugging information is 
  5920.  printed on the GDB standard output stream.  set remotedebug off turns it off, 
  5921.  and show remotedebug shows you its current state. 
  5922.  
  5923.  
  5924. ΓòÉΓòÉΓòÉ 16.4.1.5. Using the gdbserver program ΓòÉΓòÉΓòÉ
  5925.  
  5926. gdbserver is a control program for Unix-like systems, which allows you to 
  5927. connect your program with a remote GDB via target remote---but without linking 
  5928. in the usual debugging stub. 
  5929.  
  5930. gdbserver is not a complete replacement for the debugging stubs, because it 
  5931. requires essentially the same operating-system facilities that GDB itself does. 
  5932. In fact, a system that can run gdbserver to connect to a remote GDB could also 
  5933. run GDB locally!  gdbserver is sometimes useful nevertheless, because it is a 
  5934. much smaller program than GDB itself.  It is also easier to port than all of 
  5935. GDB, so you may be able to get started more quickly on a new system by using 
  5936. gdbserver. Finally, if you develop code for real-time systems, you may find 
  5937. that the tradeoffs involved in real-time operation make it more convenient to 
  5938. do as much development work as possible on another system, for example by 
  5939. cross-compiling.  You can use gdbserver to make a similar choice for debugging. 
  5940.  
  5941. GDB and gdbserver communicate via either a serial line or a TCP connection, 
  5942. using the standard GDB remote serial protocol. 
  5943.  
  5944.  On the target machine, 
  5945.            you need to have a copy of the program you want to debug. gdbserver 
  5946.            does not need your program's symbol table, so you can strip the 
  5947.            program if necessary to save space.  GDB on the host system does all 
  5948.            the symbol handling. 
  5949.  
  5950.            To use the server, you must tell it how to communicate with GDB; the 
  5951.            name of your program; and the arguments for your program.  The 
  5952.            syntax is: 
  5953.  
  5954.                       target> gdbserver comm program [ args ... ]
  5955.  
  5956.            comm is either a device name (to use a serial line) or a TCP 
  5957.            hostname and portnumber.  For example, to debug Emacs with the 
  5958.            argument `foo.txt' and communicate with GDB over the serial port 
  5959.            `/dev/com1': 
  5960.  
  5961.                       target> gdbserver /dev/com1 emacs foo.txt
  5962.  
  5963.            gdbserver waits passively for the host GDB to communicate with it. 
  5964.  
  5965.            To use a TCP connection instead of a serial line: 
  5966.  
  5967.                       target> gdbserver host:2345 emacs foo.txt
  5968.  
  5969.            The only difference from the previous example is the first argument, 
  5970.            specifying that you are communicating with the host GDB via TCP. 
  5971.            The `host:2345' argument means that gdbserver is to expect a TCP 
  5972.            connection from machine `host' to local TCP port 2345. (Currently, 
  5973.            the `host' part is ignored.)  You can choose any number you want for 
  5974.            the port number as long as it does not conflict with any TCP ports 
  5975.            already in use on the target system (for example, 23 is reserved for 
  5976.            telnet).(3) You must use the same port number with the host GDB 
  5977.            target remote command. 
  5978.  
  5979.  On the GDBN host machine, 
  5980.            you need an unstripped copy of your program, since GDB needs symbols 
  5981.            and debugging information.  Start up GDB as usual, using the name of 
  5982.            the local copy of your program as the first argument. (You may also 
  5983.            need the `--baud' option if the serial line is running at anything 
  5984.            other than 9600 bps.)  After that, use target remote to establish 
  5985.            communications with gdbserver.  Its argument is either a device name 
  5986.            (usually a serial device, like `/dev/ttyb'), or a TCP port 
  5987.            descriptor in the form host:PORT.  For example: 
  5988.  
  5989.                       (gdb) target remote /dev/ttyb
  5990.  
  5991.            communicates with the server via serial line `/dev/ttyb', and 
  5992.  
  5993.                       (gdb) target remote the-target:2345
  5994.  
  5995.            communicates via a TCP connection to port 2345 on host `the-target'. 
  5996.            For TCP connections, you must start up gdbserver prior to using the 
  5997.            target remote command.  Otherwise you may get an error whose text 
  5998.            depends on the host system, but which usually looks something like 
  5999.            `Connection refused'. 
  6000.  
  6001.  
  6002. ΓòÉΓòÉΓòÉ 16.4.1.6. Using the gdbserve.nlm program ΓòÉΓòÉΓòÉ
  6003.  
  6004. gdbserve.nlm is a control program for NetWare systems, which allows you to 
  6005. connect your program with a remote GDB via target remote. 
  6006.  
  6007. GDB and gdbserve.nlm communicate via a serial line, using the standard GDB 
  6008. remote serial protocol. 
  6009.  
  6010.  On the target machine, 
  6011.            you need to have a copy of the program you want to debug. 
  6012.            gdbserve.nlm does not need your program's symbol table, so you can 
  6013.            strip the program if necessary to save space.  GDB on the host 
  6014.            system does all the symbol handling. 
  6015.  
  6016.            To use the server, you must tell it how to communicate with GDB; the 
  6017.            name of your program; and the arguments for your program.  The 
  6018.            syntax is: 
  6019.  
  6020.                       load gdbserve [ BOARD=board ] [ PORT=port ]
  6021.                                     [ BAUD=baud ] program [ args ... ]
  6022.  
  6023.            board and port specify the serial line; baud specifies the baud rate 
  6024.            used by the connection.  port and node default to 0, baud defaults 
  6025.            to 9600 bps. 
  6026.  
  6027.            For example, to debug Emacs with the argument `foo.txt'and 
  6028.            communicate with GDB over serial port number 2 or board 1 using a 
  6029.            19200 bps connection: 
  6030.  
  6031.                       load gdbserve BOARD=1 PORT=2 BAUD=19200 emacs foo.txt
  6032.  
  6033.  On the GDBN host machine, 
  6034.            you need an unstripped copy of your program, since GDB needs symbols 
  6035.            and debugging information.  Start up GDB as usual, using the name of 
  6036.            the local copy of your program as the first argument. (You may also 
  6037.            need the `--baud' option if the serial line is running at anything 
  6038.            other than 9600 bps.  After that, use target remote to establish 
  6039.            communications with gdbserve.nlm.  Its argument is a device name 
  6040.            (usually a serial device, like `/dev/ttyb').  For example: 
  6041.  
  6042.                       (gdb) target remote /dev/ttyb
  6043.  
  6044.            communications with the server via serial line `/dev/ttyb'. 
  6045.  
  6046.  
  6047. ΓòÉΓòÉΓòÉ 16.4.2. GDB with a remote i960 (Nindy) ΓòÉΓòÉΓòÉ
  6048.  
  6049. Nindy is a ROM Monitor program for Intel 960 target systems.  When GDB is 
  6050. configured to control a remote Intel 960 using Nindy, you can tell GDB how to 
  6051. connect to the 960 in several ways: 
  6052.  
  6053.      Through command line options specifying serial port, version of the Nindy 
  6054.       protocol, and communications speed; 
  6055.  
  6056.      By responding to a prompt on startup; 
  6057.  
  6058.      By using the target command at any point during your GDB session.  See 
  6059.       Commands for managing targets. 
  6060.  
  6061.  Nindy Startup                           Startup with Nindy 
  6062.  Nindy Options                           Options for Nindy 
  6063.  Nindy Reset                             Nindy reset command 
  6064.  
  6065.  
  6066. ΓòÉΓòÉΓòÉ 16.4.2.1. Startup with Nindy ΓòÉΓòÉΓòÉ
  6067.  
  6068. If you simply start gdb without using any command-line options, you are 
  6069. prompted for what serial port to use, before you reach the ordinary GDB prompt: 
  6070.  
  6071. Attach /dev/ttyNN -- specify NN, or "quit" to quit:
  6072.  
  6073. Respond to the prompt with whatever suffix (after `/dev/tty') identifies the 
  6074. serial port you want to use.  You can, if you choose, simply start up with no 
  6075. Nindy connection by responding to the prompt with an empty line.  If you do 
  6076. this and later wish to attach to Nindy, use target (see Commands for managing 
  6077. targets). 
  6078.  
  6079.  
  6080. ΓòÉΓòÉΓòÉ 16.4.2.2. Options for Nindy ΓòÉΓòÉΓòÉ
  6081.  
  6082. These are the startup options for beginning your GDB session with a Nindy-960 
  6083. board attached: 
  6084.  
  6085.  -r port 
  6086.            Specify the serial port name of a serial interface to be used to 
  6087.            connect to the target system.  This option is only available when 
  6088.            GDB is configured for the Intel 960 target architecture.  You may 
  6089.            specify port as any of: a full pathname (e.g. `-r /dev/ttya'), a 
  6090.            device name in `/dev' (e.g. `-r ttya'), or simply the unique suffix 
  6091.            for a specific tty (e.g. `-r a'). 
  6092.  
  6093.  -O 
  6094.            (An uppercase letter ``O'', not a zero.)  Specify that GDB should 
  6095.            use the ``old'' Nindy monitor protocol to connect to the target 
  6096.            system. This option is only available when GDB is configured for the 
  6097.            Intel 960 target architecture. 
  6098.  
  6099.            Warning: if you specify `-O', but are actually trying to connect to 
  6100.            a target system that expects the newer protocol, the connection 
  6101.            fails, appearing to be a speed mismatch.  GDB repeatedly attempts to 
  6102.            reconnect at several different line speeds.  You can abort this 
  6103.            process with an interrupt. 
  6104.  
  6105.  -brk 
  6106.            Specify that GDB should first send a BREAK signal to the target 
  6107.            system, in an attempt to reset it, before connecting to a Nindy 
  6108.            target. 
  6109.  
  6110.            Warning: Many target systems do not have the hardware that this 
  6111.            requires; it only works with a few boards. 
  6112.  
  6113.  The standard `-b' option controls the line speed used on the serial port. 
  6114.  
  6115.  
  6116. ΓòÉΓòÉΓòÉ 16.4.2.3. Nindy reset command ΓòÉΓòÉΓòÉ
  6117.  
  6118.  reset 
  6119.            For a Nindy target, this command sends a ``break'' to the remote 
  6120.            target system; this is only useful if the target has been equipped 
  6121.            with a circuit to perform a hard reset (or some other interesting 
  6122.            action) when a break is detected. 
  6123.  
  6124.  
  6125. ΓòÉΓòÉΓòÉ 16.4.3. The UDI protocol for AMD29K ΓòÉΓòÉΓòÉ
  6126.  
  6127. GDB supports AMD's UDI (``Universal Debugger Interface'') protocol for 
  6128. debugging the a29k processor family.  To use this configuration with AMD 
  6129. targets running the MiniMON monitor, you need the program MONTIP, available 
  6130. from AMD at no charge.  You can also use GDB with the UDI-conformant a29k 
  6131. simulator program ISSTIP, also available from AMD. 
  6132.  
  6133.  target udi keyword 
  6134.            Select the UDI interface to a remote a29k board or simulator, where 
  6135.            keyword is an entry in the AMD configuration file `udi_soc'. This 
  6136.            file contains keyword entries which specify parameters used to 
  6137.            connect to a29k targets.  If the `udi_soc' file is not in your 
  6138.            working directory, you must set the environment variable `UDICONF' 
  6139.            to its pathname. 
  6140.  
  6141.  
  6142. ΓòÉΓòÉΓòÉ 16.4.4. The EBMON protocol for AMD29K ΓòÉΓòÉΓòÉ
  6143.  
  6144. AMD distributes a 29K development board meant to fit in a PC, together with a 
  6145. DOS-hosted monitor program called EBMON.  As a shorthand term, this development 
  6146. system is called the ``EB29K''.  To use GDB from a Unix system to run programs 
  6147. on the EB29K board, you must first connect a serial cable between the PC (which 
  6148. hosts the EB29K board) and a serial port on the Unix system.  In the following, 
  6149. we assume you've hooked the cable between the PC's `COM1' port and `/dev/ttya' 
  6150. on the Unix system. 
  6151.  
  6152.  Comms (EB29K)                           Communications setup 
  6153.  gdb-EB29K                               EB29K cross-debugging 
  6154.  Remote Log                              Remote log 
  6155.  
  6156.  
  6157. ΓòÉΓòÉΓòÉ 16.4.4.1. Communications setup ΓòÉΓòÉΓòÉ
  6158.  
  6159. The next step is to set up the PC's port, by doing something like this in DOS 
  6160. on the PC: 
  6161.  
  6162. C:\> MODE com1:9600,n,8,1,none
  6163.  
  6164. This example---run on an MS DOS 4.0 system---sets the PC port to 9600 bps, no 
  6165. parity, eight data bits, one stop bit, and no ``retry'' action; you must match 
  6166. the communications parameters when establishing the Unix end of the connection 
  6167. as well. 
  6168.  
  6169. To give control of the PC to the Unix side of the serial line, type the 
  6170. following at the DOS console: 
  6171.  
  6172. C:\> CTTY com1
  6173.  
  6174. (Later, if you wish to return control to the DOS console, you can use the 
  6175. command CTTY con---but you must send it over the device that had control, in 
  6176. our example over the `COM1' serial line). 
  6177.  
  6178. From the Unix host, use a communications program such as tip or cu to 
  6179. communicate with the PC; for example, 
  6180.  
  6181. cu -s 9600 -l /dev/ttya
  6182.  
  6183. The cu options shown specify, respectively, the linespeed and the serial port 
  6184. to use.  If you use tip instead, your command line may look something like the 
  6185. following: 
  6186.  
  6187. tip -9600 /dev/ttya
  6188.  
  6189. Your system may require a different name where we show `/dev/ttya' as the 
  6190. argument to tip.  The communications parameters, including which port to use, 
  6191. are associated with the tip argument in the ``remote'' descriptions 
  6192. file---normally the system table `/etc/remote'. 
  6193.  
  6194. Using the tip or cu connection, change the DOS working directory to the 
  6195. directory containing a copy of your 29K program, then start the PC program 
  6196. EBMON (an EB29K control program supplied with your board by AMD).  You should 
  6197. see an initial display from EBMON similar to the one that follows, ending with 
  6198. the EBMON prompt `#'--- 
  6199.  
  6200. C:\> G:
  6201.  
  6202. G:\> CD \usr\joe\work29k
  6203.  
  6204. G:\USR\JOE\WORK29K> EBMON
  6205. Am29000 PC Coprocessor Board Monitor, version 3.0-18
  6206. Copyright 1990 Advanced Micro Devices, Inc.
  6207. Written by Gibbons and Associates, Inc.
  6208.  
  6209. Enter '?' or 'H' for help
  6210.  
  6211. PC Coprocessor Type   = EB29K
  6212. I/O Base              = 0x208
  6213. Memory Base           = 0xd0000
  6214.  
  6215. Data Memory Size      = 2048KB
  6216. Available I-RAM Range = 0x8000 to 0x1fffff
  6217. Available D-RAM Range = 0x80002000 to 0x801fffff
  6218.  
  6219. PageSize              = 0x400
  6220. Register Stack Size   = 0x800
  6221. Memory Stack Size     = 0x1800
  6222.  
  6223. CPU PRL               = 0x3
  6224. Am29027 Available     = No
  6225. Byte Write Available  = Yes
  6226.  
  6227. # ~.
  6228.  
  6229. Then exit the cu or tip program (done in the example by typing ~. at the EBMON 
  6230. prompt).  EBMON keeps running, ready for GDB to take over. 
  6231.  
  6232. For this example, we've assumed what is probably the most convenient way to 
  6233. make sure the same 29K program is on both the PC and the Unix system: a PC/NFS 
  6234. connection that establishes ``drive G:'' on the PC as a file system on the Unix 
  6235. host.  If you do not have PC/NFS or something similar connecting the two 
  6236. systems, you must arrange some other way---perhaps floppy-disk transfer---of 
  6237. getting the 29K program from the Unix system to the PC; GDB does not download 
  6238. it over the serial line. 
  6239.  
  6240.  
  6241. ΓòÉΓòÉΓòÉ 16.4.4.2. EB29K cross-debugging ΓòÉΓòÉΓòÉ
  6242.  
  6243. Finally, cd to the directory containing an image of your 29K program on the 
  6244. Unix system, and start GDB---specifying as argument the name of your 29K 
  6245. program: 
  6246.  
  6247. cd /usr/joe/work29k
  6248. gdb myfoo
  6249.  
  6250. Now you can use the target command: 
  6251.  
  6252. target amd-eb /dev/ttya 9600 MYFOO
  6253.  
  6254. In this example, we've assumed your program is in a file called `myfoo'.  Note 
  6255. that the filename given as the last argument to target amd-eb should be the 
  6256. name of the program as it appears to DOS. In our example this is simply MYFOO, 
  6257. but in general it can include a DOS path, and depending on your transfer 
  6258. mechanism may not resemble the name on the Unix side. 
  6259.  
  6260. At this point, you can set any breakpoints you wish; when you are ready to see 
  6261. your program run on the 29K board, use the GDB command run. 
  6262.  
  6263. To stop debugging the remote program, use the GDB detach command. 
  6264.  
  6265. To return control of the PC to its console, use tip or cu once again, after 
  6266. your GDB session has concluded, to attach to EBMON.  You can then type the 
  6267. command q to shut down EBMON, returning control to the DOS command-line 
  6268. interpreter. Type CTTY con to return command input to the main DOS console, and 
  6269. type ~. to leave tip or cu. 
  6270.  
  6271.  
  6272. ΓòÉΓòÉΓòÉ 16.4.4.3. Remote log ΓòÉΓòÉΓòÉ
  6273.  
  6274. The target amd-eb command creates a file `eb.log' in the current working 
  6275. directory, to help debug problems with the connection. `eb.log' records all the 
  6276. output from EBMON, including echoes of the commands sent to it.  Running `tail 
  6277. -f' on this file in another window often helps to understand trouble with 
  6278. EBMON, or unexpected events on the PC side of the connection. 
  6279.  
  6280.  
  6281. ΓòÉΓòÉΓòÉ 16.4.5. GDB with a Tandem ST2000 ΓòÉΓòÉΓòÉ
  6282.  
  6283. To connect your ST2000 to the host system, see the manufacturer's manual.  Once 
  6284. the ST2000 is physically attached, you can run: 
  6285.  
  6286. target st2000 dev speed
  6287.  
  6288. to establish it as your debugging environment.  dev is normally the name of a 
  6289. serial device, such as `/dev/ttya', connected to the ST2000 via a serial line. 
  6290. You can instead specify dev as a TCP connection (for example, to a serial line 
  6291. attached via a terminal concentrator) using the syntax hostname:portnumber. 
  6292.  
  6293. The load and attach commands are not defined for this target; you must load 
  6294. your program into the ST2000 as you normally would for standalone operation. 
  6295. GDB reads debugging information (such as symbols) from a separate, debugging 
  6296. version of the program available on your host computer. 
  6297.  
  6298. These auxiliary GDB commands are available to help you with the ST2000 
  6299. environment: 
  6300.  
  6301.  st2000 command 
  6302.            Send a command to the STDBUG monitor.  See the manufacturer's manual 
  6303.            for available commands. 
  6304.  
  6305.  connect 
  6306.            Connect the controlling terminal to the STDBUG command monitor. 
  6307.            When you are done interacting with STDBUG, typing either of two 
  6308.            character sequences gets you back to the GDB command prompt: RET~. 
  6309.            (Return, followed by tilde and period) or RET~C-d (Return, followed 
  6310.            by tilde and control-D). 
  6311.  
  6312.  
  6313. ΓòÉΓòÉΓòÉ 16.4.6. GDB and VxWorks ΓòÉΓòÉΓòÉ
  6314.  
  6315. GDB enables developers to spawn and debug tasks running on networked VxWorks 
  6316. targets from a Unix host.  Already-running tasks spawned from the VxWorks shell 
  6317. can also be debugged.  GDB uses code that runs on both the Unix host and on the 
  6318. VxWorks target.  The program gdb is installed and executed on the Unix host. 
  6319. (It may be installed with the name vxgdb, to distinguish it from a GDB for 
  6320. debugging programs on the host itself.) 
  6321.  
  6322.  VxWorks-timeout args 
  6323.            All VxWorks-based targets now support the option vxworks-timeout. 
  6324.            This option is set by the user, and  args represents the number of 
  6325.            seconds GDB waits for responses to rpc's.  You might use this if 
  6326.            your VxWorks target is a slow software simulator or is on the far 
  6327.            side of a thin network line. 
  6328.  
  6329.  The following information on connecting to VxWorks was current when this 
  6330.  manual was produced; newer releases of VxWorks may use revised procedures. 
  6331.  
  6332.  To use GDB with VxWorks, you must rebuild your VxWorks kernel to include the 
  6333.  remote debugging interface routines in the VxWorks library `rdb.a'.  To do 
  6334.  this, define INCLUDE_RDB in the VxWorks configuration file `configAll.h' and 
  6335.  rebuild your VxWorks kernel.  The resulting kernel contains `rdb.a', and 
  6336.  spawns the source debugging task tRdbTask when VxWorks is booted.  For more 
  6337.  information on configuring and remaking VxWorks, see the manufacturer's 
  6338.  manual. 
  6339.  
  6340.  Once you have included `rdb.a' in your VxWorks system image and set your Unix 
  6341.  execution search path to find GDB, you are ready to run GDB.  From your Unix 
  6342.  host, run gdb (or vxgdb, depending on your installation). 
  6343.  
  6344.  GDB comes up showing the prompt: 
  6345.  
  6346.   (vxgdb)
  6347.  
  6348.  VxWorks Connection                      Connecting to VxWorks 
  6349.  VxWorks Download                        VxWorks download 
  6350.  VxWorks Attach                          Running tasks 
  6351.  
  6352.  
  6353. ΓòÉΓòÉΓòÉ 16.4.6.1. Connecting to VxWorks ΓòÉΓòÉΓòÉ
  6354.  
  6355. The GDB command target lets you connect to a VxWorks target on the network.  To 
  6356. connect to a target whose host name is ``tt'', type: 
  6357.  
  6358. (vxgdb) target vxworks tt
  6359.  
  6360. GDB displays messages like these: 
  6361.  
  6362. Attaching remote machine across net...
  6363. Connected to tt.
  6364.  
  6365. GDB then attempts to read the symbol tables of any object modules loaded into 
  6366. the VxWorks target since it was last booted.  GDB locates these files by 
  6367. searching the directories listed in the command search path (see Your program_s 
  6368. environment); if it fails to find an object file, it displays a message such 
  6369. as: 
  6370.  
  6371. prog.o: No such file or directory.
  6372.  
  6373. When this happens, add the appropriate directory to the search path with the 
  6374. GDB command path, and execute the target command again. 
  6375.  
  6376.  
  6377. ΓòÉΓòÉΓòÉ 16.4.6.2. VxWorks download ΓòÉΓòÉΓòÉ
  6378.  
  6379. If you have connected to the VxWorks target and you want to debug an object 
  6380. that has not yet been loaded, you can use the GDB load command to download a 
  6381. file from Unix to VxWorks incrementally.  The object file given as an argument 
  6382. to the load command is actually opened twice: first by the VxWorks target in 
  6383. order to download the code, then by GDB in order to read the symbol table. 
  6384. This can lead to problems if the current working directories on the two systems 
  6385. differ.  If both systems have NFS mounted the same filesystems, you can avoid 
  6386. these problems by using absolute paths. Otherwise, it is simplest to set the 
  6387. working directory on both systems to the directory in which the object file 
  6388. resides, and then to reference the file by its name, without any path.  For 
  6389. instance, a program `prog.o' may reside in `vxpath/vw/demo/rdb' in VxWorks and 
  6390. in `hostpath/vw/demo/rdb' on the host.  To load this program, type this on 
  6391. VxWorks: 
  6392.  
  6393. -> cd "vxpath/vw/demo/rdb"
  6394.  
  6395. v Then, in GDB, type: 
  6396.  
  6397. (vxgdb) cd hostpath/vw/demo/rdb
  6398. (vxgdb) load prog.o
  6399.  
  6400. GDB displays a response similar to this: 
  6401.  
  6402. Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
  6403.  
  6404. You can also use the load command to reload an object module after editing and 
  6405. recompiling the corresponding source file.  Note that this makes GDB delete all 
  6406. currently-defined breakpoints, auto-displays, and convenience variables, and to 
  6407. clear the value history.  (This is necessary in order to preserve the integrity 
  6408. of debugger data structures that reference the target system's symbol table.) 
  6409.  
  6410.  
  6411. ΓòÉΓòÉΓòÉ 16.4.6.3. Running tasks ΓòÉΓòÉΓòÉ
  6412.  
  6413. You can also attach to an existing task using the attach command as follows: 
  6414.  
  6415. (vxgdb) attach task
  6416.  
  6417. where task is the VxWorks hexadecimal task ID.  The task can be running or 
  6418. suspended when you attach to it.  Running tasks are suspended at the time of 
  6419. attachment. 
  6420.  
  6421.  Hitachi Boards                          Connecting to Hitachi boards. 
  6422.  
  6423.  
  6424.  Hitachi ICE                             Using the E7000 In-Circuit Emulator. 
  6425.  Hitachi Special                         Special GDBN commands for Hitachi 
  6426.                                          micros. 
  6427.  
  6428.  
  6429. ΓòÉΓòÉΓòÉ 16.4.6.4. Using the E7000 in-circuit emulator ΓòÉΓòÉΓòÉ
  6430.  
  6431. You can use the E7000 in-circuit emulator to develop code for either the 
  6432. Hitachi SH or the H8/300H.  Use one of these forms of the `target e7000' 
  6433. command to connect GDB to your E7000: 
  6434.  
  6435.  target e7000 port speed 
  6436.            Use this form if your E7000 is connected to a serial port.  The port 
  6437.            argument identifies what serial port to use (for example, `com2'). 
  6438.            The third argument is the line speed in bits per second (for 
  6439.            example, `9600'). 
  6440.  
  6441.  target e7000 hostname 
  6442.            If your E7000 is installed as a host on a TCP/IP network, you can 
  6443.            just specify its hostname; GDB uses telnet to connect. 
  6444.  
  6445.  
  6446. ΓòÉΓòÉΓòÉ 16.4.6.5. Special GDB commands for Hitachi micros ΓòÉΓòÉΓòÉ
  6447.  
  6448. Some GDB commands are available only on the H8/300 or the H8/500 
  6449. configurations: 
  6450.  
  6451.  set machine h8300 
  6452.  set machine h8300h 
  6453.            Condition GDB for one of the two variants of the H8/300 architecture 
  6454.            with `set machine'.  You can use `show machine' to check which 
  6455.            variant is currently in effect. 
  6456.  
  6457.  set memory mod 
  6458.  show memory 
  6459.            Specify which H8/500 memory model (mod) you are using with `set 
  6460.            memory'; check which memory model is in effect with `show memory'. 
  6461.            The accepted values for mod are small, big, medium, and compact. 
  6462.  
  6463.  
  6464. ΓòÉΓòÉΓòÉ 16.4.7. GDB and remote MIPS boards ΓòÉΓòÉΓòÉ
  6465.  
  6466. GDB can use the MIPS remote debugging protocol to talk to a MIPS board attached 
  6467. to a serial line.  This is available when you configure GDB with 
  6468. `--target=mips-idt-ecoff'. 
  6469.  
  6470. Use these GDB commands to specify the connection to your target board: 
  6471.  
  6472.  target mips port 
  6473.            To run a program on the board, start up gdb with the name of your 
  6474.            program as the argument.  To connect to the board, use the command 
  6475.            `target mips port', where port is the name of the serial port 
  6476.            connected to the board.  If the program has not already been 
  6477.            downloaded to the board, you may use the load command to download 
  6478.            it.  You can then use all the usual GDB commands. 
  6479.  
  6480.            For example, this sequence connects to the target board through a 
  6481.            serial port, and loads and runs a program called prog through the 
  6482.            debugger: 
  6483.  
  6484.                       host$ gdb prog
  6485.                       GDB is free software and ...
  6486.                       (gdb) target mips /dev/ttyb
  6487.                       (gdb) load prog
  6488.                       (gdb) run
  6489.  
  6490.  target mips hostname:portnumber 
  6491.            On some GDB host configurations, you can specify a TCP connection 
  6492.            (for instance, to a serial line managed by a terminal concentrator) 
  6493.            instead of a serial port, using the syntax `hostname:portnumber'. 
  6494.  
  6495.  GDB also supports these special commands for MIPS targets: 
  6496.  
  6497.  set processor args 
  6498.  show processor 
  6499.            Use the set processor command to set the type of MIPS processor when 
  6500.            you want to access processor-type-specific registers. For example, 
  6501.            set processor r3041 tells GDB to use the CPO registers appropriate 
  6502.            for the 3041 chip. Use the show processor command to see what MIPS 
  6503.            processor GDB is using.  Use the info reg command to see what 
  6504.            registers GDB is using. 
  6505.  
  6506.  set mipsfpu double 
  6507.  set mipsfpu single 
  6508.  set mipsfpu none 
  6509.  show mipsfpu 
  6510.            If your target board does not support the MIPS floating point 
  6511.            coprocessor, you should use the command `set mipsfpu none' (if you 
  6512.            need this, you may wish to put the command in your .gdbinit file). 
  6513.            This tells GDB how to find the return value of functions which 
  6514.            return floating point values.  It also allows GDB to avoid saving 
  6515.            the floating point registers when calling functions on the board. 
  6516.            If you are using a floating point coprocessor with only single 
  6517.            precision floating point support, as on the r4650 processor, use the 
  6518.            command `set mipsfpu single'.  The default double precision floating 
  6519.            point coprocessor may be selected using `set mipsfpu double'. 
  6520.  
  6521.            In previous versions the only choices were double precision or no 
  6522.            floating point, so `set mipsfpu on' will select double precision and 
  6523.            `set mipsfpu off' will select no floating point. 
  6524.  
  6525.            As usual, you can inquire about the mipsfpu variable with `show 
  6526.            mipsfpu'. 
  6527.  
  6528.  set remotedebug n 
  6529.  show remotedebug 
  6530.            You can see some debugging information about communications with the 
  6531.            board by setting the remotedebug variable.  If you set it to 1 using 
  6532.            `set remotedebug 1', every packet is displayed.  If you set it to 2, 
  6533.            every character is displayed.  You can check the current value at 
  6534.            any time with the command `show remotedebug'. 
  6535.  
  6536.  set timeout seconds 
  6537.  set retransmit-timeout seconds 
  6538.  show timeout 
  6539.  show retransmit-timeout 
  6540.            You can control the timeout used while waiting for a packet, in the 
  6541.            MIPS remote protocol, with the set timeout seconds command.  The 
  6542.            default is 5 seconds.  Similarly, you can control the timeout used 
  6543.            while waiting for an acknowledgement of a packet with the set 
  6544.            retransmit-timeout seconds command.  The default is 3 seconds. You 
  6545.            can inspect both values with show timeout and show 
  6546.            retransmit-timeout.  (These commands are only available when GDB is 
  6547.            configured for `--target=mips-idt-ecoff'.) 
  6548.  
  6549.            The timeout set by set timeout does not apply when GDB is waiting 
  6550.            for your program to stop.  In that case, GDB waits forever because 
  6551.            it has no way of knowing how long the program is going to run before 
  6552.            stopping. 
  6553.  
  6554.  
  6555. ΓòÉΓòÉΓòÉ 16.4.8. Simulated CPU target ΓòÉΓòÉΓòÉ
  6556.  
  6557. For some configurations, GDB includes a CPU simulator that you can use instead 
  6558. of a hardware CPU to debug your programs.  Currently, a simulator is available 
  6559. when GDB is configured to debug Zilog Z8000 or Hitachi microprocessor targets. 
  6560. For the Z8000 family, `target sim' simulates either the Z8002 (the 
  6561.  
  6562. unsegmented variant of the Z8000 architecture) or the Z8001 (the segmented 
  6563. variant).  The simulator recognizes which architecture is appropriate by 
  6564. inspecting the object code. 
  6565.  
  6566.  target sim 
  6567.            Debug programs on a simulated CPU (which CPU depends on the GDB 
  6568.            configuration) 
  6569.  
  6570.  After specifying this target, you can debug programs for the simulated CPU in 
  6571.  the same style as programs for your host computer; use the file command to 
  6572.  load a new program image, the run command to run your program, and so on. 
  6573.  
  6574.  As well as making available all the usual machine registers (see info reg), 
  6575.  this debugging target provides three additional items of information as 
  6576.  specially named registers: 
  6577.  
  6578.  cycles 
  6579.            Counts clock-ticks in the simulator. 
  6580.  
  6581.  insts 
  6582.            Counts instructions run in the simulator. 
  6583.  
  6584.  time 
  6585.            Execution time in 60ths of a second. 
  6586.  
  6587.  You can refer to these values in GDB expressions with the usual conventions; 
  6588.  for example, `b fputc if $cycles>5000' sets a conditional breakpoint that 
  6589.  suspends only after at least 5000 simulated clock ticks. 
  6590.  
  6591.  
  6592. ΓòÉΓòÉΓòÉ 17. Controlling GDB ΓòÉΓòÉΓòÉ
  6593.  
  6594. You can alter the way GDB interacts with you by using the set command.  For 
  6595. commands controlling how GDB displays data, see Print settings; other settings 
  6596. are described here. 
  6597.  
  6598.  Prompt                                  Prompt 
  6599.  Editing                                 Command editing 
  6600.  History                                 Command history 
  6601.  Screen Size                             Screen size 
  6602.  Numbers                                 Numbers 
  6603.  Messages/Warnings                       Optional warnings and messages 
  6604.  
  6605.  
  6606. ΓòÉΓòÉΓòÉ 17.1. Prompt ΓòÉΓòÉΓòÉ
  6607.  
  6608. GDB indicates its readiness to read a command by printing a string called the 
  6609. prompt.  This string is normally `(gdb)'.  You can change the prompt string 
  6610. with the set prompt command.  For instance, when debugging GDB with GDB, it is 
  6611. useful to change the prompt in one of the GDB sessions so that you can always 
  6612. tell which one you are talking to. 
  6613.  
  6614. Note:  set prompt no longer adds a space for you after the prompt you set. 
  6615. This allows you to set a prompt which ends in a space or a prompt that does 
  6616. not. 
  6617.  
  6618.  set prompt newprompt 
  6619.            Directs GDB to use newprompt as its prompt string henceforth. 
  6620.  
  6621.  show prompt 
  6622.            Prints a line of the form: `Gdb's prompt is: your-prompt' 
  6623.  
  6624.  
  6625. ΓòÉΓòÉΓòÉ 17.2. Command editing ΓòÉΓòÉΓòÉ
  6626.  
  6627. GDB reads its input commands via the readline interface.  This gnu library 
  6628. provides consistent behavior for programs which provide a command line 
  6629. interface to the user.  Advantages are gnu Emacs-style or vi-style inline 
  6630. editing of commands, csh-like history substitution, and a storage and recall of 
  6631. command history across debugging sessions. 
  6632.  
  6633. You may control the behavior of command line editing in GDB with the command 
  6634. set. 
  6635.  
  6636.  set editing 
  6637.  set editing on 
  6638.            Enable command line editing (enabled by default). 
  6639.  
  6640.  set editing off 
  6641.            Disable command line editing. 
  6642.  
  6643.  show editing 
  6644.            Show whether command line editing is enabled. 
  6645.  
  6646.  
  6647. ΓòÉΓòÉΓòÉ 17.3. Command history ΓòÉΓòÉΓòÉ
  6648.  
  6649. GDB can keep track of the commands you type during your debugging sessions, so 
  6650. that you can be certain of precisely what happened.  Use these commands to 
  6651. manage the GDB command history facility. 
  6652.  
  6653.  set history filename fname 
  6654.            Set the name of the GDB command history file to fname. This is the 
  6655.            file where GDB reads an initial command history list, and where it 
  6656.            writes the command history from this session when it exits.  You can 
  6657.            access this list through history expansion or through the history 
  6658.            command editing characters listed below.  This file defaults to the 
  6659.            value of the environment variable GDBHISTFILE, or to 
  6660.            `./.gdb_history' if this variable is not set. 
  6661.  
  6662.  set history save 
  6663.  set history save on 
  6664.            Record command history in a file, whose name may be specified with 
  6665.            the set history filename command.  By default, this option is 
  6666.            disabled. 
  6667.  
  6668.  set history save off 
  6669.            Stop recording command history in a file. 
  6670.  
  6671.  set history size size 
  6672.            Set the number of commands which GDB keeps in its history list. This 
  6673.            defaults to the value of the environment variable HISTSIZE, or to 
  6674.            256 if this variable is not set. 
  6675.  
  6676.  History expansion assigns special meaning to the character !. 
  6677.  
  6678.  Since ! is also the logical not operator in C, history expansion is off by 
  6679.  default. If you decide to enable history expansion with the set history 
  6680.  expansion on command, you may sometimes need to follow ! (when it is used as 
  6681.  logical not, in an expression) with a space or a tab to prevent it from being 
  6682.  expanded.  The readline history facilities do not attempt substitution on the 
  6683.  strings != and !(, even when history expansion is enabled. 
  6684.  
  6685.  The commands to control history expansion are: 
  6686.  
  6687.  set history expansion on 
  6688.  set history expansion 
  6689.            Enable history expansion.  History expansion is off by default. 
  6690.  
  6691.  set history expansion off 
  6692.            Disable history expansion. 
  6693.  
  6694.            The readline code comes with more complete documentation of editing 
  6695.            and history expansion features.  Users unfamiliar with gnu Emacs or 
  6696.            vi may wish to read it. 
  6697.  
  6698.  show history 
  6699.  show history filename 
  6700.  show history save 
  6701.  show history size 
  6702.  show history expansion 
  6703.            These commands display the state of the GDB history parameters. show 
  6704.            history by itself displays all four states. 
  6705.  
  6706.  show commands 
  6707.            Display the last ten commands in the command history. 
  6708.  
  6709.  show commands n 
  6710.            Print ten commands centered on command number n. 
  6711.  
  6712.  show commands + 
  6713.            Print ten commands just after the commands last printed. 
  6714.  
  6715.  
  6716. ΓòÉΓòÉΓòÉ 17.4. Screen size ΓòÉΓòÉΓòÉ
  6717.  
  6718. Certain commands to GDB may produce large amounts of information output to the 
  6719. screen.  To help you read all of it, GDB pauses and asks you for input at the 
  6720. end of each page of output.  Type RET when you want to continue the output, or 
  6721. q to discard the remaining output.  Also, the screen width setting determines 
  6722. when to wrap lines of output.  Depending on what is being printed, GDB tries to 
  6723. break the line at a readable place, rather than simply letting it overflow onto 
  6724. the following line. 
  6725.  
  6726. Normally GDB knows the size of the screen from the termcap data base together 
  6727. with the value of the TERM environment variable and the stty rows and stty cols 
  6728. settings. If this is not correct, you can override it with the set height and 
  6729. set width commands: 
  6730.  
  6731.  set height lpp 
  6732.  show height 
  6733.  set width cpl 
  6734.  show width 
  6735.            These set commands specify a screen height of lpp lines and a screen 
  6736.            width of cpl characters.  The associated show commands display the 
  6737.            current settings. 
  6738.  
  6739.            If you specify a height of zero lines, GDB does not pause during 
  6740.            output no matter how long the output is.  This is useful if output 
  6741.            is to a file or to an editor buffer. 
  6742.  
  6743.            Likewise, you can specify `set width 0' to prevent GDB from wrapping 
  6744.            its output. 
  6745.  
  6746.  
  6747. ΓòÉΓòÉΓòÉ 17.5. Numbers ΓòÉΓòÉΓòÉ
  6748.  
  6749. You can always enter numbers in octal, decimal, or hexadecimal in GDB by the 
  6750. usual conventions: octal numbers begin with `0', decimal numbers end with `.', 
  6751. and hexadecimal numbers begin with `0x'. Numbers that begin with none of these 
  6752. are, by default, entered in base 10; likewise, the default display for 
  6753. numbers---when no particular format is specified---is base 10.  You can change 
  6754. the default base for both input and output with the set radix command. 
  6755.  
  6756.  set input-radix base 
  6757.            Set the default base for numeric input.  Supported choices for base 
  6758.            are decimal 8, 10, or 16.  base must itself be specified either 
  6759.            unambiguously or using the current default radix; for example, any 
  6760.            of 
  6761.  
  6762.                       set radix 012
  6763.                       set radix 10.
  6764.                       set radix 0xa
  6765.  
  6766.            sets the base to decimal.  On the other hand, `set radix 10' leaves 
  6767.            the radix unchanged no matter what it was. 
  6768.  
  6769.  set output-radix base 
  6770.            Set the default base for numeric display.  Supported choices for 
  6771.            base are decimal 8, 10, or 16.  base must itself be specified either 
  6772.            unambiguously or using the current default radix. 
  6773.  
  6774.  show input-radix 
  6775.            Display the current default base for numeric input. 
  6776.  
  6777.  show output-radix 
  6778.            Display the current default base for numeric display. 
  6779.  
  6780.  
  6781. ΓòÉΓòÉΓòÉ 17.6. Optional warnings and messages ΓòÉΓòÉΓòÉ
  6782.  
  6783. By default, GDB is silent about its inner workings.  If you are running on a 
  6784. slow machine, you may want to use the set verbose command. This makes GDB tell 
  6785. you when it does a lengthy internal operation, so you will not think it has 
  6786. crashed. 
  6787.  
  6788. Currently, the messages controlled by set verbose are those which announce that 
  6789. the symbol table for a source file is being read; see symbol-file in Commands 
  6790. to specify files. 
  6791.  
  6792.  set verbose on 
  6793.            Enables GDB output of certain informational messages. 
  6794.  
  6795.  set verbose off 
  6796.            Disables GDB output of certain informational messages. 
  6797.  
  6798.  show verbose 
  6799.            Displays whether set verbose is on or off. 
  6800.  
  6801.  By default, if GDB encounters bugs in the symbol table of an object file, it 
  6802.  is silent; but if you are debugging a compiler, you may find this information 
  6803.  useful (see Errors reading symbol files). 
  6804.  
  6805.  set complaints limit 
  6806.            Permits GDB to output limit complaints about each type of unusual 
  6807.            symbols before becoming silent about the problem.  Set limit to zero 
  6808.            to suppress all complaints; set it to a large number to prevent 
  6809.            complaints from being suppressed. 
  6810.  
  6811.  show complaints 
  6812.            Displays how many symbol complaints GDB is permitted to produce. 
  6813.  
  6814.  By default, GDB is cautious, and asks what sometimes seems to be a lot of 
  6815.  stupid questions to confirm certain commands.  For example, if you try to run 
  6816.  a program which is already running: 
  6817.  
  6818.   (gdb) run
  6819.   The program being debugged has been started already.
  6820.   Start it from the beginning? (y or n)
  6821.  
  6822.  If you are willing to unflinchingly face the consequences of your own 
  6823.  commands, you can disable this ``feature'': 
  6824.  
  6825.  set confirm off 
  6826.            Disables confirmation requests. 
  6827.  
  6828.  set confirm on 
  6829.            Enables confirmation requests (the default). 
  6830.  
  6831.  show confirm 
  6832.            Displays state of confirmation requests. 
  6833.  
  6834.  
  6835. ΓòÉΓòÉΓòÉ 18. Canned Sequences of Commands ΓòÉΓòÉΓòÉ
  6836.  
  6837. Aside from breakpoint commands ( see Breakpoint command lists), GDB provides 
  6838. two ways to store sequences of commands for execution as a unit: user-defined 
  6839. commands and command files. 
  6840.  
  6841.  Define                                  User-defined commands 
  6842.  Hooks                                   User-defined command hooks 
  6843.  Command Files                           Command files 
  6844.  Output                                  Commands for controlled output 
  6845.  
  6846.  
  6847. ΓòÉΓòÉΓòÉ 18.1. User-defined commands ΓòÉΓòÉΓòÉ
  6848.  
  6849. A user-defined command is a sequence of GDB commands to which you assign a new 
  6850. name as a command.  This is done with the define command.  User commands may 
  6851. accept up to 10 arguments separated by whitespace. Arguments are accessed 
  6852. within the user command via $arg0...$arg9. A trivial example: 
  6853.  
  6854. define adder
  6855.   print $arg0 + $arg1 + $arg2
  6856.  
  6857. To execute the command use: 
  6858.  
  6859. adder 1 2 3
  6860.  
  6861. This defines the command adder, which prints the sum of its three arguments. 
  6862. Note the arguments are text substitutions, so they may reference variables, use 
  6863. complex expressions, or even perform inferior functions calls. 
  6864.  
  6865.  define commandname 
  6866.            Define a command named commandname.  If there is already a command 
  6867.            by that name, you are asked to confirm that you want to redefine it. 
  6868.  
  6869.            The definition of the command is made up of other GDB command lines, 
  6870.            which are given following the define command.  The end of these 
  6871.            commands is marked by a line containing end. 
  6872.  
  6873.  if 
  6874.            Takes a single argument, which is an expression to evaluate. It is 
  6875.            followed by a series of commands that are executed only if the 
  6876.            expression is true (nonzero). There can then optionally be a line 
  6877.            else, followed by a series of commands that are only executed if the 
  6878.            expression was false.  The end of the list is marked by a line 
  6879.            containing end. 
  6880.  
  6881.  while 
  6882.            The syntax is similar to if: the command takes a single argument, 
  6883.            which is an expression to evaluate, and must be followed by the 
  6884.            commands to execute, one per line, terminated by an end. The 
  6885.            commands are executed repeatedly as long as the expression evaluates 
  6886.            to true. 
  6887.  
  6888.  document commandname 
  6889.            Document the user-defined command commandname, so that it can be 
  6890.            accessed by help.  The command commandname must already be defined. 
  6891.            This command reads lines of documentation just as define reads the 
  6892.            lines of the command definition, ending with end. After the document 
  6893.            command is finished, help on command commandname displays the 
  6894.            documentation you have written. 
  6895.  
  6896.            You may use the document command again to change the documentation 
  6897.            of a command.  Redefining the command with define does not change 
  6898.            the documentation. 
  6899.  
  6900.  help user-defined 
  6901.            List all user-defined commands, with the first line of the 
  6902.            documentation (if any) for each. 
  6903.  
  6904.  show user 
  6905.  show user commandname 
  6906.            Display the GDB commands used to define commandname (but not its 
  6907.            documentation).  If no commandname is given, display the definitions 
  6908.            for all user-defined commands. 
  6909.  
  6910.  When user-defined commands are executed, the commands of the definition are 
  6911.  not printed.  An error in any command stops execution of the user-defined 
  6912.  command. 
  6913.  
  6914.  If used interactively, commands that would ask for confirmation proceed 
  6915.  without asking when used inside a user-defined command.  Many GDB commands 
  6916.  that normally print messages to say what they are doing omit the messages when 
  6917.  used in a user-defined command. 
  6918.  
  6919.  
  6920. ΓòÉΓòÉΓòÉ 18.2. User-defined command hooks ΓòÉΓòÉΓòÉ
  6921.  
  6922. You may define hooks, which are a special kind of user-defined command. 
  6923. Whenever you run the command `foo', if the user-defined command `hook-foo' 
  6924. exists, it is executed (with no arguments) before that command. 
  6925.  
  6926. In addition, a pseudo-command, `stop' exists.  Defining (`hook-stop') makes the 
  6927. associated commands execute every time execution stops in your program: before 
  6928. breakpoint commands are run, displays are printed, or the stack frame is 
  6929. printed. 
  6930.  
  6931. For example, to ignore SIGALRM signals while single-stepping, but treat them 
  6932. normally during normal execution, you could define: 
  6933.  
  6934. define hook-stop
  6935. handle SIGALRM nopass
  6936. end
  6937.  
  6938. define hook-run
  6939. handle SIGALRM pass
  6940. end
  6941.  
  6942. define hook-continue
  6943. handle SIGLARM pass
  6944. end
  6945.  
  6946. You can define a hook for any single-word command in GDB, but not for command 
  6947. aliases; you should define a hook for the basic command name, e.g.  backtrace 
  6948. rather than bt. If an error occurs during the execution of your hook, execution 
  6949. of GDB commands stops and GDB issues a prompt (before the command that you 
  6950. actually typed had a chance to run). 
  6951.  
  6952. If you try to define a hook which does not match any known command, you get a 
  6953. warning from the define command. 
  6954.  
  6955.  
  6956. ΓòÉΓòÉΓòÉ 18.3. Command files ΓòÉΓòÉΓòÉ
  6957.  
  6958. A command file for GDB is a file of lines that are GDB commands.  Comments 
  6959. (lines starting with #) may also be included. An empty line in a command file 
  6960. does nothing; it does not mean to repeat the last command, as it would from the 
  6961. terminal. 
  6962.  
  6963. When you start GDB, it automatically executes commands from its init files. 
  6964. These are files named `.gdbinit'. GDB reads the init file (if any) in your home 
  6965. directory, then processes command line options and operands, and then reads the 
  6966. init file (if any) in the current working directory.  This is so the init file 
  6967. in your home directory can set options (such as set complaints) which affect 
  6968. the processing of the command line options and operands.  The init files are 
  6969. not executed if you use the `-nx' option; see Choosing modes. 
  6970.  
  6971. On some configurations of GDB, the init file is known by a different name 
  6972. (these are typically environments where a specialized form of GDB may need to 
  6973. coexist with other forms, hence a different name for the specialized version's 
  6974. init file).  These are the environments with special init file names: 
  6975.  
  6976.      VxWorks (Wind River Systems real-time OS): `.vxgdbinit' 
  6977.  
  6978.      OS68K (Enea Data Systems real-time OS): `.os68gdbinit' 
  6979.  
  6980.      ES-1800 (Ericsson Telecom AB M68000 emulator): `.esgdbinit' 
  6981.  
  6982.  You can also request the execution of a command file with the source command: 
  6983.  
  6984.  source filename 
  6985.            Execute the command file filename. 
  6986.  
  6987.  The lines in a command file are executed sequentially.  They are not printed 
  6988.  as they are executed.  An error in any command terminates execution of the 
  6989.  command file. 
  6990.  
  6991.  Commands that would ask for confirmation if used interactively proceed without 
  6992.  asking when used in a command file.  Many GDB commands that normally print 
  6993.  messages to say what they are doing omit the messages when called from command 
  6994.  files. 
  6995.  
  6996.  
  6997. ΓòÉΓòÉΓòÉ 18.4. Commands for controlled output ΓòÉΓòÉΓòÉ
  6998.  
  6999. During the execution of a command file or a user-defined command, normal GDB 
  7000. output is suppressed; the only output that appears is what is explicitly 
  7001. printed by the commands in the definition.  This section describes three 
  7002. commands useful for generating exactly the output you want. 
  7003.  
  7004.  echo text 
  7005.            Print text.  Nonprinting characters can be included in text using C 
  7006.            escape sequences, such as `\n' to print a newline.  *No newline is 
  7007.            printed unless you specify one.* In addition to the standard C 
  7008.            escape sequences, a backslash followed by a space stands for a 
  7009.            space.  This is useful for displaying a string with spaces at the 
  7010.            beginning or the end, since leading and trailing spaces are 
  7011.            otherwise trimmed from all arguments. To print `and foo =', use the 
  7012.            command `echo \and foo = \'. 
  7013.  
  7014.            A backslash at the end of text can be used, as in C, to continue the 
  7015.            command onto subsequent lines.  For example, 
  7016.  
  7017.                       echo This is some text\n\
  7018.                       which is continued\n\
  7019.                       onto several lines.\n
  7020.  
  7021.            produces the same output as 
  7022.  
  7023.                       echo This is some text\n
  7024.                       echo which is continued\n
  7025.                       echo onto several lines.\n
  7026.  
  7027.  output expression 
  7028.            Print the value of expression and nothing but that value: no 
  7029.            newlines, no `$nn = '.  The value is not entered in the value 
  7030.            history either.  See Expressions, for more information on 
  7031.            expressions. 
  7032.  
  7033.  output/fmt expression 
  7034.            Print the value of expression in format fmt.  You can use the same 
  7035.            formats as for print. See Output formats, for more information. 
  7036.  
  7037.  printf string, expressions... 
  7038.            Print the values of the expressions under the control of string. 
  7039.            The expressions are separated by commas and may be either numbers or 
  7040.            pointers.  Their values are printed as specified by string, exactly 
  7041.            as if your program were to execute the C subroutine 
  7042.  
  7043.                       printf (string, expressions...);
  7044.  
  7045.            For example, you can print two values in hex like this: 
  7046.  
  7047.                       printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
  7048.  
  7049.            The only backslash-escape sequences that you can use in the format 
  7050.            string are the simple ones that consist of backslash followed by a 
  7051.            letter. 
  7052.  
  7053.  
  7054. ΓòÉΓòÉΓòÉ 19. Using GDB under gnu Emacs ΓòÉΓòÉΓòÉ
  7055.  
  7056. A special interface allows you to use gnu Emacs to view (and edit) the source 
  7057. files for the program you are debugging with GDB. 
  7058.  
  7059. To use this interface, use the command M-x gdb in Emacs.  Give the executable 
  7060. file you want to debug as an argument.  This command starts GDB as a subprocess 
  7061. of Emacs, with input and output through a newly created Emacs buffer. 
  7062.  
  7063. Using GDB under Emacs is just like using GDB normally except for two things: 
  7064.  
  7065.      All ``terminal'' input and output goes through the Emacs buffer. 
  7066.  
  7067.  This applies both to GDB commands and their output, and to the input and 
  7068.  output done by the program you are debugging. 
  7069.  
  7070.  This is useful because it means that you can copy the text of previous 
  7071.  commands and input them again; you can even use parts of the output in this 
  7072.  way. 
  7073.  
  7074.  All the facilities of Emacs' Shell mode are available for interacting with 
  7075.  your program.  In particular, you can send signals the usual way---for 
  7076.  example, C-c C-c for an interrupt, C-c C-z for a stop. 
  7077.  
  7078.      GDB displays source code through Emacs. 
  7079.  
  7080.  Each time GDB displays a stack frame, Emacs automatically finds the source 
  7081.  file for that frame and puts an arrow (`=>') at the left margin of the current 
  7082.  line.  Emacs uses a separate buffer for source display, and splits the screen 
  7083.  to show both your GDB session and the source. 
  7084.  
  7085.  Explicit GDB list or search commands still produce output as usual, but you 
  7086.  probably have no reason to use them from Emacs. 
  7087.  
  7088.  Warning: If the directory where your program resides is not your current 
  7089.  directory, it can be easy to confuse Emacs about the location of the source 
  7090.  files, in which case the auxiliary display buffer does not appear to show your 
  7091.  source.  GDB can find programs by searching your environment's PATH variable, 
  7092.  so the GDB input and output session proceeds normally; but Emacs does not get 
  7093.  enough information back from GDB to locate the source files in this situation. 
  7094.  To avoid this problem, either start GDB mode from the directory where your 
  7095.  program resides, or specify an absolute file name when prompted for the M-x 
  7096.  gdb argument. 
  7097.  
  7098.  A similar confusion can result if you use the GDB file command to switch to 
  7099.  debugging a program in some other location, from an existing GDB buffer in 
  7100.  Emacs. 
  7101.  
  7102.  By default, M-x gdb calls the program called `gdb'.  If you need to call GDB 
  7103.  by a different name (for example, if you keep several configurations around, 
  7104.  with different names) you can set the Emacs variable gdb-command-name; for 
  7105.  example, 
  7106.  
  7107.   (setq gdb-command-name "mygdb")
  7108.  
  7109.  (preceded by ESC ESC, or typed in the *scratch* buffer, or in your `.emacs' 
  7110.  file) makes Emacs call the program named ``mygdb'' instead. 
  7111.  
  7112.  In the GDB I/O buffer, you can use these special Emacs commands in addition to 
  7113.  the standard Shell mode commands: 
  7114.  
  7115.  C-h m 
  7116.            Describe the features of Emacs' GDB Mode. 
  7117.  
  7118.  M-s 
  7119.            Execute to another source line, like the GDB step command; also 
  7120.            update the display window to show the current file and location. 
  7121.  
  7122.  M-n 
  7123.            Execute to next source line in this function, skipping all function 
  7124.            calls, like the GDB next command.  Then update the display window to 
  7125.            show the current file and location. 
  7126.  
  7127.  M-i 
  7128.            Execute one instruction, like the GDB stepi command; update display 
  7129.            window accordingly. 
  7130.  
  7131.  M-x gdb-nexti 
  7132.            Execute to next instruction, using the GDB nexti command; update 
  7133.            display window accordingly. 
  7134.  
  7135.  C-c C-f 
  7136.            Execute until exit from the selected stack frame, like the GDB 
  7137.            finish command. 
  7138.  
  7139.  M-c 
  7140.            Continue execution of your program, like the GDB continue command. 
  7141.  
  7142.            Warning: In Emacs v19, this command is C-c C-p. 
  7143.  
  7144.  M-u 
  7145.            Go up the number of frames indicated by the numeric argument (see 
  7146.            Numeric Arguments), like the GDB up command. 
  7147.  
  7148.            Warning: In Emacs v19, this command is C-c C-u. 
  7149.  
  7150.  M-d 
  7151.            Go down the number of frames indicated by the numeric argument, like 
  7152.            the GDB down command. 
  7153.  
  7154.            Warning: In Emacs v19, this command is C-c C-d. 
  7155.  
  7156.  C-x & 
  7157.            Read the number where the cursor is positioned, and insert it at the 
  7158.            end of the GDB I/O buffer.  For example, if you wish to disassemble 
  7159.            code around an address that was displayed earlier, type disassemble; 
  7160.            then move the cursor to the address display, and pick up the 
  7161.            argument for disassemble by typing C-x &. 
  7162.  
  7163.            You can customize this further by defining elements of the list 
  7164.            gdb-print-command; once it is defined, you can format or otherwise 
  7165.            process numbers picked up by C-x & before they are inserted.  A 
  7166.            numeric argument to C-x & indicates that you wish special 
  7167.            formatting, and also acts as an index to pick an element of the 
  7168.            list.  If the list element is a string, the number to be inserted is 
  7169.            formatted using the Emacs function format; otherwise the number is 
  7170.            passed as an argument to the corresponding list element. 
  7171.  
  7172.  In any source file, the Emacs command C-x SPC (gdb-break) tells GDB to set a 
  7173.  breakpoint on the source line point is on. 
  7174.  
  7175.  If you accidentally delete the source-display buffer, an easy way to get it 
  7176.  back is to type the command f in the GDB buffer, to request a frame display; 
  7177.  when you run under Emacs, this recreates the source buffer if necessary to 
  7178.  show you the context of the current frame. 
  7179.  
  7180.  The source files displayed in Emacs are in ordinary Emacs buffers which are 
  7181.  visiting the source files in the usual way.  You can edit the files with these 
  7182.  buffers if you wish; but keep in mind that GDB communicates with Emacs in 
  7183.  terms of line numbers.  If you add or delete lines from the text, the line 
  7184.  numbers that GDB knows cease to correspond properly with the code. 
  7185.  
  7186.  
  7187. ΓòÉΓòÉΓòÉ 20. Reporting Bugs in GDB ΓòÉΓòÉΓòÉ
  7188.  
  7189. Your bug reports play an essential role in making GDB reliable. 
  7190.  
  7191. Reporting a bug may help you by bringing a solution to your problem, or it may 
  7192. not.  But in any case the principal function of a bug report is to help the 
  7193. entire community by making the next version of GDB work better.  Bug reports 
  7194. are your contribution to the maintenance of GDB. 
  7195.  
  7196. In order for a bug report to serve its purpose, you must include the 
  7197. information that enables us to fix the bug. 
  7198.  
  7199.  Bug Criteria                            Have you found a bug? 
  7200.  Bug Reporting                           How to report bugs 
  7201.  
  7202.  
  7203. ΓòÉΓòÉΓòÉ 20.1. Have you found a bug? ΓòÉΓòÉΓòÉ
  7204.  
  7205. If you are not sure whether you have found a bug, here are some guidelines: 
  7206.  
  7207.      If the debugger gets a fatal signal, for any input whatever, that is a 
  7208.       GDB bug.  Reliable debuggers never crash. 
  7209.  
  7210.      If GDB produces an error message for valid input, that is a bug. 
  7211.  
  7212.      If GDB does not produce an error message for invalid input, that is a 
  7213.       bug.  However, you should note that your idea of ``invalid input'' might 
  7214.       be our idea of ``an extension'' or ``support for traditional practice''. 
  7215.  
  7216.      If you are an experienced user of debugging tools, your suggestions for 
  7217.       improvement of GDB are welcome in any case. 
  7218.  
  7219.  
  7220. ΓòÉΓòÉΓòÉ 20.2. How to report bugs ΓòÉΓòÉΓòÉ
  7221.  
  7222. A number of companies and individuals offer support for gnu products. If you 
  7223. obtained GDB from a support organization, we recommend you contact that 
  7224. organization first. 
  7225.  
  7226. You can find contact information for many support companies and individuals in 
  7227. the file `etc/SERVICE' in the gnu Emacs distribution. 
  7228.  
  7229. In any event, we also recommend that you send bug reports for GDB to one of 
  7230. these addresses: 
  7231.  
  7232. bug-gdb@prep.ai.mit.edu
  7233. {ucbvax|mit-eddie|uunet}!prep.ai.mit.edu!bug-gdb
  7234.  
  7235. *Do not send bug reports to `info-gdb', or to `help-gdb', or to any 
  7236. newsgroups.* Most users of GDB do not want to receive bug reports.  Those that 
  7237. do have arranged to receive `bug-gdb'. 
  7238.  
  7239. The mailing list `bug-gdb' has a newsgroup `gnu.gdb.bug' which serves as a 
  7240. repeater.  The mailing list and the newsgroup carry exactly the same messages. 
  7241. Often people think of posting bug reports to the newsgroup instead of mailing 
  7242. them.  This appears to work, but it has one problem which can be crucial: a 
  7243. newsgroup posting often lacks a mail path back to the sender.  Thus, if we need 
  7244. to ask for more information, we may be unable to reach you.  For this reason, 
  7245. it is better to send bug reports to the mailing list. 
  7246.  
  7247. As a last resort, send bug reports on paper to: 
  7248.  
  7249. gnu Debugger Bugs
  7250. Free Software Foundation Inc.
  7251. 59 Temple Place - Suite 330
  7252. Boston, MA 02111-1307
  7253. USA
  7254.  
  7255. The fundamental principle of reporting bugs usefully is this: *report all the 
  7256. facts*.  If you are not sure whether to state a fact or leave it out, state it! 
  7257.  
  7258. Often people omit facts because they think they know what causes the problem 
  7259. and assume that some details do not matter.  Thus, you might assume that the 
  7260. name of the variable you use in an example does not matter. Well, probably it 
  7261. does not, but one cannot be sure.  Perhaps the bug is a stray memory reference 
  7262. which happens to fetch from the location where that name is stored in memory; 
  7263. perhaps, if the name were different, the contents of that location would fool 
  7264. the debugger into doing the right thing despite the bug.  Play it safe and give 
  7265. a specific, complete example.  That is the easiest thing for you to do, and the 
  7266. most helpful. 
  7267.  
  7268. Keep in mind that the purpose of a bug report is to enable us to fix the bug if 
  7269. it is new to us. Therefore, always write your bug reports on the assumption 
  7270. that the bug has not been reported previously. 
  7271.  
  7272. Sometimes people give a few sketchy facts and ask, ``Does this ring a bell?'' 
  7273. Those bug reports are useless, and we urge everyone to refuse to respond to 
  7274. them except to chide the sender to report bugs properly. 
  7275.  
  7276. To enable us to fix the bug, you should include all these things: 
  7277.  
  7278.      The version of GDB.  GDB announces it if you start with no arguments; you 
  7279.       can also print it at any time using show version. 
  7280.  
  7281.       Without this, we will not know whether there is any point in looking for 
  7282.       the bug in the current version of GDB. 
  7283.  
  7284.      The type of machine you are using, and the operating system name and 
  7285.       version number. 
  7286.  
  7287.      What compiler (and its version) was used to compile GDB---e.g. 
  7288.       ``gcc--2.0''. 
  7289.  
  7290.      What compiler (and its version) was used to compile the program you are 
  7291.       debugging---e.g.  ``gcc--2.0''. 
  7292.  
  7293.      The command arguments you gave the compiler to compile your example and 
  7294.       observe the bug.  For example, did you use `-O'?  To guarantee you will 
  7295.       not omit something important, list them all.  A copy of the Makefile (or 
  7296.       the output from make) is sufficient. 
  7297.  
  7298.       If we were to try to guess the arguments, we would probably guess wrong 
  7299.       and then we might not encounter the bug. 
  7300.  
  7301.      A complete input script, and all necessary source files, that will 
  7302.       reproduce the bug. 
  7303.  
  7304.      A description of what behavior you observe that you believe is incorrect. 
  7305.       For example, ``It gets a fatal signal.'' 
  7306.  
  7307.       Of course, if the bug is that GDB gets a fatal signal, then we will 
  7308.       certainly notice it.  But if the bug is incorrect output, we might not 
  7309.       notice unless it is glaringly wrong.  You might as well not give us a 
  7310.       chance to make a mistake. 
  7311.  
  7312.       Even if the problem you experience is a fatal signal, you should still 
  7313.       say so explicitly.  Suppose something strange is going on, such as, your 
  7314.       copy of GDB is out of synch, or you have encountered a bug in the C 
  7315.       library on your system.  (This has happened!)  Your copy might crash and 
  7316.       ours would not.  If you told us to expect a crash, then when ours fails 
  7317.       to crash, we would know that the bug was not happening for us.  If you 
  7318.       had not told us to expect a crash, then we would not be able to draw any 
  7319.       conclusion from our observations. 
  7320.  
  7321.      If you wish to suggest changes to the GDB source, send us context diffs. 
  7322.       If you even discuss something in the GDB source, refer to it by context, 
  7323.       not by line number. 
  7324.  
  7325.       The line numbers in our development sources will not match those in your 
  7326.       sources.  Your line numbers would convey no useful information to us. 
  7327.  
  7328.  Here are some things that are not necessary: 
  7329.  
  7330.      A description of the envelope of the bug. 
  7331.  
  7332.       Often people who encounter a bug spend a lot of time investigating which 
  7333.       changes to the input file will make the bug go away and which changes 
  7334.       will not affect it. 
  7335.  
  7336.       This is often time consuming and not very useful, because the way we will 
  7337.       find the bug is by running a single example under the debugger with 
  7338.       breakpoints, not by pure deduction from a series of examples. We 
  7339.       recommend that you save your time for something else. 
  7340.  
  7341.       Of course, if you can find a simpler example to report instead of the 
  7342.       original one, that is a convenience for us.  Errors in the output will be 
  7343.       easier to spot, running under the debugger will take less time, and so 
  7344.       on. 
  7345.  
  7346.       However, simplification is not vital; if you do not want to do this, 
  7347.       report the bug anyway and send us the entire test case you used. 
  7348.  
  7349.      A patch for the bug. 
  7350.  
  7351.       A patch for the bug does help us if it is a good one.  But do not omit 
  7352.       the necessary information, such as the test case, on the assumption that 
  7353.       a patch is all we need.  We might see problems with your patch and decide 
  7354.       to fix the problem another way, or we might not understand it at all. 
  7355.  
  7356.       Sometimes with a program as complicated as GDB it is very hard to 
  7357.       construct an example that will make the program follow a certain path 
  7358.       through the code.  If you do not send us the example, we will not be able 
  7359.       to construct one, so we will not be able to verify that the bug is fixed. 
  7360.  
  7361.       And if we cannot understand what bug you are trying to fix, or why your 
  7362.       patch should be an improvement, we will not install it.  A test case will 
  7363.       help us to understand. 
  7364.  
  7365.      A guess about what the bug is or what it depends on. 
  7366.  
  7367.       Such guesses are usually wrong.  Even we cannot guess right about such 
  7368.       things without first using the debugger to find the facts. 
  7369.  
  7370.  
  7371. ΓòÉΓòÉΓòÉ 21. Command Line Editing ΓòÉΓòÉΓòÉ
  7372.  
  7373. This text describes GNU's command line editing interface. 
  7374.  
  7375.  Introduction and Notation               Notation used in this text. 
  7376.  Readline Interaction                    The minimum set of commands for 
  7377.                                          editing a line. 
  7378.  Readline Init File                      Customizing Readline from a user's 
  7379.                                          view. 
  7380.  
  7381.  
  7382. ΓòÉΓòÉΓòÉ 21.1. Introduction to Line Editing ΓòÉΓòÉΓòÉ
  7383.  
  7384. The following paragraphs describe the notation we use to represent keystrokes. 
  7385.  
  7386. The text C-k is read as `Control-K' and describes the character produced when 
  7387. the Control key is depressed and the k key is struck. 
  7388.  
  7389. The text M-k is read as `Meta-K' and describes the character produced when the 
  7390. meta key (if you have one) is depressed, and the k key is struck.  If you do 
  7391. not have a meta key, the identical keystroke can be generated by typing ESC 
  7392. first, and then typing k. Either process is known as metafying the k key. 
  7393.  
  7394. The text M-C-k is read as `Meta-Control-k' and describes the character produced 
  7395. by metafying C-k. 
  7396.  
  7397. In addition, several keys have their own names.  Specifically, DEL, ESC, LFD, 
  7398. SPC, RET, and TAB all stand for themselves when seen in this text, or in an 
  7399. init file (see Readline Init File, for more info). 
  7400.  
  7401.  
  7402. ΓòÉΓòÉΓòÉ 21.2. Readline Interaction ΓòÉΓòÉΓòÉ
  7403.  
  7404. Often during an interactive session you type in a long line of text, only to 
  7405. notice that the first word on the line is misspelled.  The Readline library 
  7406. gives you a set of commands for manipulating the text as you type it in, 
  7407. allowing you to just fix your typo, and not forcing you to retype the majority 
  7408. of the line.  Using these editing commands, you move the cursor to the place 
  7409. that needs correction, and delete or insert the text of the corrections.  Then, 
  7410. when you are satisfied with the line, you simply press RET.  You do not have to 
  7411. be at the end of the line to press RET; the entire line is accepted regardless 
  7412. of the location of the cursor within the line. 
  7413.  
  7414.  Readline Bare Essentials                The least you need to know about 
  7415.                                          Readline. 
  7416.  Readline Movement Commands              Moving about the input line. 
  7417.  Readline Killing Commands               How to delete text, and how to get it 
  7418.                                          back! 
  7419.  Readline Arguments                      Giving numeric arguments to commands. 
  7420.  
  7421.  
  7422. ΓòÉΓòÉΓòÉ 21.2.1. Readline Bare Essentials ΓòÉΓòÉΓòÉ
  7423.  
  7424. In order to enter characters into the line, simply type them.  The typed 
  7425. character appears where the cursor was, and then the cursor moves one space to 
  7426. the right.  If you mistype a character, you can use DEL to back up, and delete 
  7427. the mistyped character. 
  7428.  
  7429. Sometimes you may miss typing a character that you wanted to type, and not 
  7430. notice your error until you have typed several other characters.  In that case, 
  7431. you can type C-b to move the cursor to the left, and then correct your mistake. 
  7432. Aftwerwards, you can move the cursor to the right with C-f. 
  7433.  
  7434. When you add text in the middle of a line, you will notice that characters to 
  7435. the right of the cursor get `pushed over' to make room for the text that you 
  7436. have inserted.  Likewise, when you delete text behind the cursor, characters to 
  7437. the right of the cursor get `pulled back' to fill in the blank space created by 
  7438. the removal of the text.  A list of the basic bare essentials for editing the 
  7439. text of an input line follows. 
  7440.  
  7441.  C-b 
  7442.            Move back one character. 
  7443.  
  7444.  C-f 
  7445.            Move forward one character. 
  7446.  
  7447.  DEL 
  7448.            Delete the character to the left of the cursor. 
  7449.  
  7450.  C-d 
  7451.            Delete the character underneath the cursor. 
  7452.  
  7453.  Printing characters 
  7454.            Insert itself into the line at the cursor. 
  7455.  
  7456.  C-_ 
  7457.            Undo the last thing that you did.  You can undo all the way back to 
  7458.            an empty line. 
  7459.  
  7460.  
  7461. ΓòÉΓòÉΓòÉ 21.2.2. Readline Movement Commands ΓòÉΓòÉΓòÉ
  7462.  
  7463. The above table describes the most basic possible keystrokes that you need in 
  7464. order to do editing of the input line.  For your convenience, many other 
  7465. commands have been added in addition to C-b, C-f, C-d, and DEL.  Here are some 
  7466. commands for moving more rapidly about the line. 
  7467.  
  7468.  C-a 
  7469.            Move to the start of the line. 
  7470.  
  7471.  C-e 
  7472.            Move to the end of the line. 
  7473.  
  7474.  M-f 
  7475.            Move forward a word. 
  7476.  
  7477.  M-b 
  7478.            Move backward a word. 
  7479.  
  7480.  C-l 
  7481.            Clear the screen, reprinting the current line at the top. 
  7482.  
  7483.  Notice how C-f moves forward a character, while M-f moves forward a word.  It 
  7484.  is a loose convention that control keystrokes operate on characters while meta 
  7485.  keystrokes operate on words. 
  7486.  
  7487.  
  7488. ΓòÉΓòÉΓòÉ 21.2.3. Readline Killing Commands ΓòÉΓòÉΓòÉ
  7489.  
  7490. Killing text means to delete the text from the line, but to save it away for 
  7491. later use, usually by yanking it back into the line. If the description for a 
  7492. command says that it `kills' text, then you can be sure that you can get the 
  7493. text back in a different (or the same) place later. 
  7494.  
  7495. Here is the list of commands for killing text. 
  7496.  
  7497.  C-k 
  7498.            Kill the text from the current cursor position to the end of the 
  7499.            line. 
  7500.  
  7501.  M-d 
  7502.            Kill from the cursor to the end of the current word, or if between 
  7503.            words, to the end of the next word. 
  7504.  
  7505.  M-DEL 
  7506.            Kill from the cursor to the start of the previous word, or if 
  7507.            between words, to the start of the previous word. 
  7508.  
  7509.  C-w 
  7510.            Kill from the cursor to the previous whitespace.  This is different 
  7511.            than M-DEL because the word boundaries differ. 
  7512.  
  7513.  And, here is how to yank the text back into the line. 
  7514.  
  7515.  C-y 
  7516.            Yank the most recently killed text back into the buffer at the 
  7517.            cursor. 
  7518.  
  7519.  M-y 
  7520.            Rotate the kill-ring, and yank the new top.  You can only do this if 
  7521.            the prior command is C-y or M-y. 
  7522.  
  7523.  When you use a kill command, the text is saved in a kill-ring. Any number of 
  7524.  consecutive kills save all of the killed text together, so that when you yank 
  7525.  it back, you get it in one clean sweep.  The kill ring is not line specific; 
  7526.  the text that you killed on a previously typed line is available to be yanked 
  7527.  back later, when you are typing another line. 
  7528.  
  7529.  
  7530. ΓòÉΓòÉΓòÉ 21.2.4. Readline Arguments ΓòÉΓòÉΓòÉ
  7531.  
  7532. You can pass numeric arguments to Readline commands.  Sometimes the argument 
  7533. acts as a repeat count, other times it is the sign of the argument that is 
  7534. significant.  If you pass a negative argument to a command which normally acts 
  7535. in a forward direction, that command will act in a backward direction.  For 
  7536. example, to kill text back to the start of the line, you might type M-- C-k. 
  7537.  
  7538. The general way to pass numeric arguments to a command is to type meta digits 
  7539. before the command.  If the first `digit' you type is a minus sign (-), then 
  7540. the sign of the argument will be negative.  Once you have typed one meta digit 
  7541. to get the argument started, you can type the remainder of the digits, and then 
  7542. the command.  For example, to give the C-d command an argument of 10, you could 
  7543. type M-1 0 C-d. 
  7544.  
  7545.  
  7546. ΓòÉΓòÉΓòÉ 21.3. Readline Init File ΓòÉΓòÉΓòÉ
  7547.  
  7548. Although the Readline library comes with a set of gnu Emacs-like keybindings, 
  7549. it is possible that you would like to use a different set of keybindings.  You 
  7550. can customize programs that use Readline by putting commands in an init file in 
  7551. your home directory.  The name of this file is `~/.inputrc'. 
  7552.  
  7553. When a program which uses the Readline library starts up, the `~/.inputrc' file 
  7554. is read, and the keybindings are set. 
  7555.  
  7556. In addition, the C-x C-r command re-reads this init file, thus incorporating 
  7557. any changes that you might have made to it. 
  7558.  
  7559.  Readline Init Syntax                    Syntax for the commands in ~/.inputrc. 
  7560.  Readline vi Mode                        Switching to vi mode in Readline. 
  7561.  
  7562.  
  7563. ΓòÉΓòÉΓòÉ 21.3.1. Readline Init Syntax ΓòÉΓòÉΓòÉ
  7564.  
  7565. There are only four constructs allowed in the `~/.inputrc' file: 
  7566.  
  7567.  Variable Settings 
  7568.            You can change the state of a few variables in Readline.  You do 
  7569.            this by using the set command within the init file.  Here is how you 
  7570.            would specify that you wish to use vi line editing commands: 
  7571.  
  7572.                       set editing-mode vi
  7573.  
  7574.            Right now, there are only a few variables which can be set; so few 
  7575.            in fact, that we just iterate them here: 
  7576.  
  7577.            editing-mode 
  7578.                           The editing-mode variable controls which editing mode 
  7579.                           you are using.  By default, gnu Readline starts up in 
  7580.                           Emacs editing mode, where the keystrokes are most 
  7581.                           similar to Emacs.  This variable can either be set to 
  7582.                           emacs or vi. 
  7583.  
  7584.            horizontal-scroll-mode 
  7585.                           This variable can either be set to On or Off. 
  7586.                           Setting it to On means that the text of the lines 
  7587.                           that you edit will scroll horizontally on a single 
  7588.                           screen line when they are larger than the width of 
  7589.                           the screen, instead of wrapping onto a new screen 
  7590.                           line.  By default, this variable is set to Off. 
  7591.  
  7592.            mark-modified-lines 
  7593.                           This variable when set to On, says to display an 
  7594.                           asterisk (`*') at the starts of history lines which 
  7595.                           have been modified. This variable is off by default. 
  7596.  
  7597.            prefer-visible-bell 
  7598.                           If this variable is set to On it means to use a 
  7599.                           visible bell if one is available, rather than simply 
  7600.                           ringing the terminal bell.  By default, the value is 
  7601.                           Off. 
  7602.  
  7603.  Key Bindings 
  7604.            The syntax for controlling keybindings in the `~/.inputrc' file is 
  7605.            simple.  First you have to know the name of the command that you 
  7606.            want to change.  The following pages contain tables of the command 
  7607.            name, the default keybinding, and a short description of what the 
  7608.            command does. 
  7609.  
  7610.            Once you know the name of the command, simply place the name of the 
  7611.            key you wish to bind the command to, a colon, and then the name of 
  7612.            the command on a line in the `~/.inputrc' file.  The name of the key 
  7613.            can be expressed in different ways, depending on which is most 
  7614.            comfortable for you. 
  7615.  
  7616.            keyname: function-name or macro 
  7617.                           keyname is the name of a key spelled out in English. 
  7618.                           For example: 
  7619.  
  7620.                                                     Control-u: universal-argument
  7621.                                                     Meta-Rubout: backward-kill-word
  7622.                                                     Control-o: ">&output"
  7623.  
  7624.                           In the above example, C-u is bound to the function 
  7625.                           universal-argument, and C-o is bound to run the macro 
  7626.                           expressed on the right hand side (that is, to insert 
  7627.                           the text `>&output' into the line). 
  7628.  
  7629.            "keyseq": function-name or macro 
  7630.                           keyseq differs from keyname above in that strings 
  7631.                           denoting an entire key sequence can be specified. 
  7632.                           Simply place the key sequence in double quotes.  gnu 
  7633.                           Emacs style key escapes can be used, as in the 
  7634.                           following example: 
  7635.  
  7636.                                                     "\C-u": universal-argument
  7637.                                                     "\C-x\C-r": re-read-init-file
  7638.                                                     "\e[11~": "Function Key 1"
  7639.  
  7640.                           In the above example, C-u is bound to the function 
  7641.                           universal-argument (just as it was in the first 
  7642.                           example), C-x C-r is bound to the function 
  7643.                           re-read-init-file, and ESC [ 1 1 ~ is bound to insert 
  7644.                           the text `Function Key 1'. 
  7645.  
  7646.  Commands For Moving                     Moving about the line. 
  7647.  Commands For History                    Getting at previous lines. 
  7648.  Commands For Text                       Commands for changing text. 
  7649.  Commands For Killing                    Commands for killing and yanking. 
  7650.  Numeric Arguments                       Specifying numeric arguments, repeat 
  7651.                                          counts. 
  7652.  Commands For Completion                 Getting Readline to do the typing for 
  7653.                                          you. 
  7654.  Miscellaneous Commands                  Other miscillaneous commands. 
  7655.  
  7656.  
  7657. ΓòÉΓòÉΓòÉ 21.3.1.1. Commands For Moving ΓòÉΓòÉΓòÉ
  7658.  
  7659.  beginning-of-line (C-a) 
  7660.            Move to the start of the current line. 
  7661.  
  7662.  end-of-line (C-e) 
  7663.            Move to the end of the line. 
  7664.  
  7665.  forward-char (C-f) 
  7666.            Move forward a character. 
  7667.  
  7668.  backward-char (C-b) 
  7669.            Move back a character. 
  7670.  
  7671.  forward-word (M-f) 
  7672.            Move forward to the end of the next word. 
  7673.  
  7674.  backward-word (M-b) 
  7675.            Move back to the start of this, or the previous, word. 
  7676.  
  7677.  clear-screen (C-l) 
  7678.            Clear the screen leaving the current line at the top of the screen. 
  7679.  
  7680.  
  7681. ΓòÉΓòÉΓòÉ 21.3.1.2. Commands For Manipulating The History ΓòÉΓòÉΓòÉ
  7682.  
  7683.  accept-line (Newline, Return) 
  7684.            Accept the line regardless of where the cursor is.  If this line is 
  7685.            non-empty, add it to the history list.  If this line was a history 
  7686.            line, then restore the history line to its original state. 
  7687.  
  7688.  previous-history (C-p) 
  7689.            Move `up' through the history list. 
  7690.  
  7691.  next-history (C-n) 
  7692.            Move `down' through the history list. 
  7693.  
  7694.  beginning-of-history (M-<) 
  7695.            Move to the first line in the history. 
  7696.  
  7697.  end-of-history (M->) 
  7698.            Move to the end of the input history, i.e., the line you are 
  7699.            entering. 
  7700.  
  7701.  reverse-search-history (C-r) 
  7702.            Search backward starting at the current line and moving `up' through 
  7703.            the history as necessary.  This is an incremental search. 
  7704.  
  7705.  forward-search-history (C-s) 
  7706.            Search forward starting at the current line and moving `down' 
  7707.            through the the history as necessary. 
  7708.  
  7709.  
  7710. ΓòÉΓòÉΓòÉ 21.3.1.3. Commands For Changing Text ΓòÉΓòÉΓòÉ
  7711.  
  7712.  delete-char (C-d) 
  7713.            Delete the character under the cursor.  If the cursor is at the 
  7714.            beginning of the line, and there are no characters in the line, and 
  7715.            the last character typed was not C-d, then return EOF. 
  7716.  
  7717.  backward-delete-char (Rubout) 
  7718.            Delete the character behind the cursor.  A numeric argument says to 
  7719.            kill the characters instead of deleting them. 
  7720.  
  7721.  quoted-insert (C-q, C-v) 
  7722.            Add the next character that you type to the line verbatim.  This is 
  7723.            how to insert things like C-q for example. 
  7724.  
  7725.  tab-insert (M-TAB) 
  7726.            Insert a tab character. 
  7727.  
  7728.  self-insert (a, b, A, 1, !, ...) 
  7729.            Insert yourself. 
  7730.  
  7731.  transpose-chars (C-t) 
  7732.            Drag the character before point forward over the character at point. 
  7733.            Point moves forward as well.  If point is at the end of the line, 
  7734.            then transpose the two characters before point.  Negative arguments 
  7735.            don't work. 
  7736.  
  7737.  transpose-words (M-t) 
  7738.            Drag the word behind the cursor past the word in front of the cursor 
  7739.            moving the cursor over that word as well. 
  7740.  
  7741.  upcase-word (M-u) 
  7742.            Uppercase all letters in the current (or following) word.  With a 
  7743.            negative argument, do the previous word, but do not move point. 
  7744.  
  7745.  downcase-word (M-l) 
  7746.            Lowercase all letters in the current (or following) word.  With a 
  7747.            negative argument, do the previous word, but do not move point. 
  7748.  
  7749.  capitalize-word (M-c) 
  7750.            Uppercase the first letter in the current (or following) word.  With 
  7751.            a negative argument, do the previous word, but do not move point. 
  7752.  
  7753.  
  7754. ΓòÉΓòÉΓòÉ 21.3.1.4. Killing And Yanking ΓòÉΓòÉΓòÉ
  7755.  
  7756.  kill-line (C-k) 
  7757.            Kill the text from the current cursor position to the end of the 
  7758.            line. 
  7759.  
  7760.  backward-kill-line () 
  7761.            Kill backward to the beginning of the line.  This is normally 
  7762.            unbound. 
  7763.  
  7764.  kill-word (M-d) 
  7765.            Kill from the cursor to the end of the current word, or if between 
  7766.            words, to the end of the next word. 
  7767.  
  7768.  backward-kill-word (M-DEL) 
  7769.            Kill the word behind the cursor. 
  7770.  
  7771.  unix-line-discard (C-u) 
  7772.            Kill the whole line the way C-u used to in Unix line input. The 
  7773.            killed text is saved on the kill-ring. 
  7774.  
  7775.  unix-word-rubout (C-w) 
  7776.            Kill the word the way C-w used to in Unix line input. The killed 
  7777.            text is saved on the kill-ring.  This is different than 
  7778.            backward-kill-word because the word boundaries differ. 
  7779.  
  7780.  yank (C-y) 
  7781.            Yank the top of the kill ring into the buffer at point. 
  7782.  
  7783.  yank-pop (M-y) 
  7784.            Rotate the kill-ring, and yank the new top.  You can only do this if 
  7785.            the prior command is yank or yank-pop. 
  7786.  
  7787.  
  7788. ΓòÉΓòÉΓòÉ 21.3.1.5. Specifying Numeric Arguments ΓòÉΓòÉΓòÉ
  7789.  
  7790.  digit-argument (M-0, M-1, ... M--) 
  7791.            Add this digit to the argument already accumulating, or start a new 
  7792.            argument.  M-- starts a negative argument. 
  7793.  
  7794.  universal-argument () 
  7795.            Do what C-u does in gnu Emacs.  By default, this is not bound. 
  7796.  
  7797.  
  7798. ΓòÉΓòÉΓòÉ 21.3.1.6. Letting Readline Type For You ΓòÉΓòÉΓòÉ
  7799.  
  7800.  complete (TAB) 
  7801.            Attempt to do completion on the text before point.  This is 
  7802.            implementation defined.  Generally, if you are typing a filename 
  7803.            argument, you can do filename completion; if you are typing a 
  7804.            command, you can do command completion, if you are typing in a 
  7805.            symbol to GDB, you can do symbol name completion, if you are typing 
  7806.            in a variable to Bash, you can do variable name completion. 
  7807.  
  7808.  possible-completions (M-?) 
  7809.            List the possible completions of the text before point. 
  7810.  
  7811.  
  7812. ΓòÉΓòÉΓòÉ 21.3.1.7. Some Miscellaneous Commands ΓòÉΓòÉΓòÉ
  7813.  
  7814.  re-read-init-file (C-x C-r) 
  7815.            Read in the contents of your `~/.inputrc' file, and incorporate any 
  7816.            bindings found there. 
  7817.  
  7818.  abort (C-g) 
  7819.            Stop running the current editing command. 
  7820.  
  7821.  prefix-meta (ESC) 
  7822.            Make the next character that you type be metafied.  This is for 
  7823.            people without a meta key.  Typing ESC f is equivalent to typing 
  7824.            M-f. 
  7825.  
  7826.  undo (C-_) 
  7827.            Incremental undo, separately remembered for each line. 
  7828.  
  7829.  revert-line (M-r) 
  7830.            Undo all changes made to this line.  This is like typing the `undo' 
  7831.            command enough times to get back to the beginning. 
  7832.  
  7833.  
  7834. ΓòÉΓòÉΓòÉ 21.3.2. Readline vi Mode ΓòÉΓòÉΓòÉ
  7835.  
  7836. While the Readline library does not have a full set of vi editing functions, it 
  7837. does contain enough to allow simple editing of the line. 
  7838.  
  7839. In order to switch interactively between gnu Emacs and vi editing modes, use 
  7840. the command M-C-j (toggle-editing-mode). 
  7841.  
  7842. When you enter a line in vi mode, you are already placed in `insertion' mode, 
  7843. as if you had typed an `i'.  Pressing ESC switches you into `edit' mode, where 
  7844. you can edit the text of the line with the standard vi movement keys, move to 
  7845. previous history lines with `k', and following lines with `j', and so forth. 
  7846.  
  7847.  
  7848. ΓòÉΓòÉΓòÉ 22. Using History Interactively ΓòÉΓòÉΓòÉ
  7849.  
  7850. This chapter describes how to use the GNU History Library interactively, from a 
  7851. user's standpoint. 
  7852.  
  7853.  History Interaction                     What it feels like using History as a 
  7854.                                          user. 
  7855.  
  7856.  
  7857. ΓòÉΓòÉΓòÉ 22.1. History Interaction ΓòÉΓòÉΓòÉ
  7858.  
  7859. The History library provides a history expansion feature similar to the history 
  7860. expansion in csh.  The following text describes the syntax you use to 
  7861. manipulate history information. 
  7862.  
  7863. History expansion takes two parts.  In the first part, determine which line 
  7864. from the previous history will be used for substitution. This line is called 
  7865. the event. In the second part, select portions of that line for inclusion into 
  7866. the current line.  These portions are called words. GDB breaks the line into 
  7867. words in the same way that the Bash shell does, so that several English (or 
  7868. Unix) words surrounded by quotes are considered one word. 
  7869.  
  7870.  Event Designators                       How to specify which history line to 
  7871.                                          use. 
  7872.  Word Designators                        Specifying which words are of 
  7873.                                          interest. 
  7874.  Modifiers                               Modifying the results of 
  7875.                                          susbstitution. 
  7876.  
  7877.  
  7878. ΓòÉΓòÉΓòÉ 22.1.1. Event Designators ΓòÉΓòÉΓòÉ
  7879.  
  7880. An event designator is a reference to a command line entry in the history list. 
  7881.  
  7882.  ! 
  7883.            Start a history subsititution, except when followed by a space, tab, 
  7884.            or the end of the line... = or (. 
  7885.  
  7886.  !! 
  7887.            Refer to the previous command.  This is a synonym for !-1. 
  7888.  
  7889.  !n 
  7890.            Refer to command line n. 
  7891.  
  7892.  !-n 
  7893.            Refer to the command line n lines back. 
  7894.  
  7895.  !string 
  7896.            Refer to the most recent command starting with string. 
  7897.  
  7898.  !?string[?] 
  7899.            Refer to the most recent command containing string. 
  7900.  
  7901.  
  7902. ΓòÉΓòÉΓòÉ 22.1.2. Word Designators ΓòÉΓòÉΓòÉ
  7903.  
  7904. A : separates the event designator from the word designator. It can be omitted 
  7905. if the word designator begins with a ^, $, * or %.  Words are numbered from the 
  7906. beginning of the line, with the first word being denoted by a 0 (zero). 
  7907.  
  7908.  0 (zero) 
  7909.            The zero'th word.  For many applications, this is the command word. 
  7910.  
  7911.  n 
  7912.            The n'th word. 
  7913.  
  7914.  ^ 
  7915.            The first argument.  that is, word 1. 
  7916.  
  7917.  $ 
  7918.            The last argument. 
  7919.  
  7920.  % 
  7921.            The word matched by the most recent ?string? search. 
  7922.  
  7923.  x-y 
  7924.            A range of words; -y Abbreviates 0-y. 
  7925.  
  7926.  * 
  7927.            All of the words, excepting the zero'th.  This is a synonym for 1-$. 
  7928.            It is not an error to use * if there is just one word in the event. 
  7929.            The empty string is returned in that case. 
  7930.  
  7931.  
  7932. ΓòÉΓòÉΓòÉ 22.1.3. Modifiers ΓòÉΓòÉΓòÉ
  7933.  
  7934. After the optional word designator, you can add a sequence of one or more of 
  7935. the following modifiers, each preceded by a :. 
  7936.  
  7937.  # 
  7938.            The entire command line typed so far.  This means the current 
  7939.            command, not the previous command. 
  7940.  
  7941.  h 
  7942.            Remove a trailing pathname component, leaving only the head. 
  7943.  
  7944.  r 
  7945.            Remove a trailing suffix of the form `.'suffix, leaving the 
  7946.            basename. 
  7947.  
  7948.  e 
  7949.            Remove all but the suffix. 
  7950.  
  7951.  t 
  7952.            Remove all leading  pathname  components, leaving the tail. 
  7953.  
  7954.  p 
  7955.            Print the new command but do not execute it. 
  7956.  
  7957.  
  7958. ΓòÉΓòÉΓòÉ 23. Formatting Documentation ΓòÉΓòÉΓòÉ
  7959.  
  7960. The GDB 4 release includes an already-formatted reference card, ready for 
  7961. printing with PostScript or Ghostscript, in the `gdb' subdirectory of the main 
  7962. source directory(4).  If you can use PostScript or Ghostscript with your 
  7963. printer, you can print the reference card immediately with `refcard.ps'. 
  7964.  
  7965. The release also includes the source for the reference card.  You can format 
  7966. it, using TeX, by typing: 
  7967.  
  7968. make refcard.dvi
  7969.  
  7970. The GDB reference card is designed to print in landscape mode on US ``letter'' 
  7971. size paper; that is, on a sheet 11 inches wide by 8.5 inches high.  You will 
  7972. need to specify this form of printing as an option to your dvi output program. 
  7973.  
  7974. All the documentation for GDB comes as part of the machine-readable 
  7975. distribution.  The documentation is written in Texinfo format, which is a 
  7976. documentation system that uses a single source file to produce both on-line 
  7977. information and a printed manual.  You can use one of the Info formatting 
  7978. commands to create the on-line version of the documentation and TeX (or 
  7979. texi2roff) to typeset the printed version. 
  7980.  
  7981. GDB includes an already formatted copy of the on-line Info version of this 
  7982. manual in the `gdb' subdirectory.  The main Info file is 
  7983. `gdb-version-number/gdb/gdb.info', and it refers to subordinate files matching 
  7984. `gdb.info*' in the same directory.  If necessary, you can print out these 
  7985. files, or read them with any editor; but they are easier to read using the info 
  7986. subsystem in gnu Emacs or the standalone info program, available as part of the 
  7987. gnu Texinfo distribution. 
  7988.  
  7989. If you want to format these Info files yourself, you need one of the Info 
  7990. formatting programs, such as texinfo-format-buffer or makeinfo. 
  7991.  
  7992. If you have makeinfo installed, and are in the top level GDB source directory 
  7993. (`gdb-4.16', in the case of version 4.16), you can make the Info file by 
  7994. typing: 
  7995.  
  7996. cd gdb
  7997. make gdb.info
  7998.  
  7999. If you want to typeset and print copies of this manual, you need TeX, a program 
  8000. to print its dvi output files, and `texinfo.tex', the Texinfo definitions file. 
  8001.  
  8002. TeX is a typesetting program; it does not print files directly, but produces 
  8003. output files called dvi files.  To print a typeset document, you need a program 
  8004. to print dvi files.  If your system has TeX installed, chances are it has such 
  8005. a program.  The precise command to use depends on your system; lpr -d is 
  8006. common; another (for PostScript devices) is dvips.  The dvi print command may 
  8007. require a file name without any extension or a `.dvi' extension. 
  8008.  
  8009. TeX also requires a macro definitions file called `texinfo.tex'.  This file 
  8010. tells TeX how to typeset a document written in Texinfo format.  On its own, TeX 
  8011. cannot either read or typeset a Texinfo file.  `texinfo.tex' is distributed 
  8012. with GDB and is located in the `gdb-version-number/texinfo' directory. 
  8013.  
  8014. If you have TeX and a dvi printer program installed, you can typeset and print 
  8015. this manual.  First switch to the the `gdb' subdirectory of the main source 
  8016. directory (for example, to `gdb-4.16/gdb') and then type: 
  8017.  
  8018. make gdb.dvi
  8019.  
  8020.  
  8021. ΓòÉΓòÉΓòÉ 24. Installing GDB ΓòÉΓòÉΓòÉ
  8022.  
  8023. GDB comes with a configure script that automates the process of preparing GDB 
  8024. for installation; you can then use make to build the gdb program. 
  8025.  
  8026. The GDB distribution includes all the source code you need for GDB in a single 
  8027. directory, whose name is usually composed by appending the version number to 
  8028. `gdb'. 
  8029.  
  8030. For example, the GDB version 4.16 distribution is in the `gdb-4.16' directory. 
  8031. That directory contains: 
  8032.  
  8033.  gdb-GDBVN/configure (and supporting files) 
  8034.            script for configuring GDB and all its supporting libraries 
  8035.  
  8036.  gdb-GDBVN/gdb 
  8037.            the source specific to GDB itself 
  8038.  
  8039.  gdb-GDBVN/bfd 
  8040.            source for the Binary File Descriptor library 
  8041.  
  8042.  gdb-GDBVN/include 
  8043.            gnu include files 
  8044.  
  8045.  gdb-GDBVN/libiberty 
  8046.            source for the `-liberty' free software library 
  8047.  
  8048.  gdb-GDBVN/opcodes 
  8049.            source for the library of opcode tables and disassemblers 
  8050.  
  8051.  gdb-GDBVN/readline 
  8052.            source for the gnu command-line interface 
  8053.  
  8054.  gdb-GDBVN/glob 
  8055.            source for the gnu filename pattern-matching subroutine 
  8056.  
  8057.  gdb-GDBVN/mmalloc 
  8058.            source for the gnu memory-mapped malloc package 
  8059.  
  8060.  The simplest way to configure and build GDB is to run configure from the 
  8061.  `gdb-version-number' source directory, which in this example is the `gdb-4.16' 
  8062.  directory. 
  8063.  
  8064.  First switch to the `gdb-version-number' source directory if you are not 
  8065.  already in it; then run configure.  Pass the identifier for the platform on 
  8066.  which GDB will run as an argument. 
  8067.  
  8068.  For example: 
  8069.  
  8070.   cd gdb-4.16
  8071.   ./configure host
  8072.   make
  8073.  
  8074.  where host is an identifier such as `sun4' or `decstation', that identifies 
  8075.  the platform where GDB will run. (You can often leave off host; configure 
  8076.  tries to guess the correct value by examining your system.) 
  8077.  
  8078.  Running `configure host' and then running make builds the `bfd', `readline', 
  8079.  `mmalloc', and `libiberty' libraries, then gdb itself.  The configured source 
  8080.  files, and the binaries, are left in the corresponding source directories. 
  8081.  
  8082.  configure is a Bourne-shell (/bin/sh) script; if your system does not 
  8083.  recognize this automatically when you run a different shell, you may need to 
  8084.  run sh on it explicitly: 
  8085.  
  8086.   sh configure host
  8087.  
  8088.  If you run configure from a directory that contains source directories for 
  8089.  multiple libraries or programs, such as the `gdb-4.16' source directory for 
  8090.  version 4.16, configure creates configuration files for every directory level 
  8091.  underneath (unless you tell it not to, with the `--norecursion' option). 
  8092.  
  8093.  You can run the configure script from any of the subordinate directories in 
  8094.  the GDB distribution if you only want to configure that subdirectory, but be 
  8095.  sure to specify a path to it. 
  8096.  
  8097.  For example, with version 4.16, type the following to configure only the bfd 
  8098.  subdirectory: 
  8099.  
  8100.   cd gdb-4.16/bfd
  8101.   ../configure host
  8102.  
  8103.  You can install gdb anywhere; it has no hardwired paths. However, you should 
  8104.  make sure that the shell on your path (named by the `SHELL' environment 
  8105.  variable) is publicly readable.  Remember that GDB uses the shell to start 
  8106.  your program---some systems refuse to let GDB debug child processes whose 
  8107.  programs are not readable. 
  8108.  
  8109.  Separate Objdir                         Compiling GDBN in another directory 
  8110.  Config Names                            Specifying names for hosts and targets 
  8111.  configure Options                       Summary of options for configure 
  8112.  
  8113.  
  8114. ΓòÉΓòÉΓòÉ 24.1. Compiling GDB in another directory ΓòÉΓòÉΓòÉ
  8115.  
  8116. If you want to run GDB versions for several host or target machines, you need a 
  8117. different gdb compiled for each combination of host and target.  configure is 
  8118. designed to make this easy by allowing you to generate each configuration in a 
  8119. separate subdirectory, rather than in the source directory.  If your make 
  8120. program handles the `VPATH' feature (gnu make does), running make in each of 
  8121. these directories builds the gdb program specified there. 
  8122.  
  8123. To build gdb in a separate directory, run configure with the `--srcdir' option 
  8124. to specify where to find the source. (You also need to specify a path to find 
  8125. configure itself from your working directory.  If the path to configure would 
  8126. be the same as the argument to `--srcdir', you can leave out the `--srcdir' 
  8127. option; it is assumed.) 
  8128.  
  8129. For example, with version 4.16, you can build GDB in a separate directory for a 
  8130. Sun 4 like this: 
  8131.  
  8132. cd gdb-4.16
  8133. mkdir ../gdb-sun4
  8134. cd ../gdb-sun4
  8135. ../gdb-4.16/configure sun4
  8136. make
  8137.  
  8138. When configure builds a configuration using a remote source directory, it 
  8139. creates a tree for the binaries with the same structure (and using the same 
  8140. names) as the tree under the source directory.  In the example, you'd find the 
  8141. Sun 4 library `libiberty.a' in the directory `gdb-sun4/libiberty', and GDB 
  8142. itself in `gdb-sun4/gdb'. 
  8143.  
  8144. One popular reason to build several GDB configurations in separate directories 
  8145. is to configure GDB for cross-compiling (where GDB runs on one machine---the 
  8146. host---while debugging programs that run on another machine---the target). You 
  8147. specify a cross-debugging target by giving the `--target=target' option to 
  8148. configure. 
  8149.  
  8150. When you run make to build a program or library, you must run it in a 
  8151. configured directory---whatever directory you were in when you called configure 
  8152. (or one of its subdirectories). 
  8153.  
  8154. The Makefile that configure generates in each source directory also runs 
  8155. recursively.  If you type make in a source directory such as `gdb-4.16' (or in 
  8156. a separate configured directory configured with `--srcdir=dirname/gdb-4.16'), 
  8157. you will build all the required libraries, and then build GDB. 
  8158.  
  8159. When you have multiple hosts or targets configured in separate directories, you 
  8160. can run make on them in parallel (for example, if they are NFS-mounted on each 
  8161. of the hosts); they will not interfere with each other. 
  8162.  
  8163.  
  8164. ΓòÉΓòÉΓòÉ 24.2. Specifying names for hosts and targets ΓòÉΓòÉΓòÉ
  8165.  
  8166. The specifications used for hosts and targets in the configure script are based 
  8167. on a three-part naming scheme, but some short predefined aliases are also 
  8168. supported.  The full naming scheme encodes three pieces of information in the 
  8169. following pattern: 
  8170.  
  8171. architecture-vendor-os
  8172.  
  8173. For example, you can use the alias sun4 as a host argument, or as the value for 
  8174. target in a --target=target option.  The equivalent full name is 
  8175. `sparc-sun-sunos4'. 
  8176.  
  8177. The configure script accompanying GDB does not provide any query facility to 
  8178. list all supported host and target names or aliases.  configure calls the 
  8179. Bourne shell script config.sub to map abbreviations to full names; you can read 
  8180. the script, if you wish, or you can use it to test your guesses on 
  8181. abbreviations---for example: 
  8182.  
  8183. % sh config.sub sun4
  8184. sparc-sun-sunos4.1.1
  8185. % sh config.sub sun3
  8186. m68k-sun-sunos4.1.1
  8187. % sh config.sub decstation
  8188. mips-dec-ultrix4.2
  8189. % sh config.sub hp300bsd
  8190. m68k-hp-bsd
  8191. % sh config.sub i386v
  8192. i386-unknown-sysv
  8193. % sh config.sub i786v
  8194. Invalid configuration `i786v': machine `i786v' not recognized
  8195.  
  8196. config.sub is also distributed in the GDB source directory (`gdb-4.16', for 
  8197. version 4.16). 
  8198.  
  8199.  
  8200. ΓòÉΓòÉΓòÉ 24.3. configure options ΓòÉΓòÉΓòÉ
  8201.  
  8202. Here is a summary of the configure options and arguments that are most often 
  8203. useful for building GDB.  configure also has several other options not listed 
  8204. here.  See Info file What Configure Does,,configure.info, for a full 
  8205. explanation of configure. 
  8206.  
  8207. configure [--help]
  8208.           [--prefix=dir]
  8209.           [--srcdir=dirname]
  8210.           [--norecursion] [--rm]
  8211.           [--target=target] host
  8212.  
  8213. You may introduce options with a single `-' rather than `--' if you prefer; but 
  8214. you may abbreviate option names if you use `--'. 
  8215.  
  8216.  --help 
  8217.            Display a quick summary of how to invoke configure. 
  8218.  
  8219.  -prefix=dir 
  8220.            Configure the source to install programs and files under directory 
  8221.            `dir'. 
  8222.  
  8223.  --srcdir=dirname 
  8224.            *Warning: using this option requires gnu make, or another make that 
  8225.            implements the VPATH feature.* 
  8226.            Use this option to make configurations in directories separate from 
  8227.            the GDB source directories.  Among other things, you can use this to 
  8228.            build (or maintain) several configurations simultaneously, in 
  8229.            separate directories.  configure writes configuration specific files 
  8230.            in the current directory, but arranges for them to use the source in 
  8231.            the directory dirname.  configure creates directories under the 
  8232.            working directory in parallel to the source directories below 
  8233.            dirname. 
  8234.  
  8235.  --norecursion 
  8236.            Configure only the directory level where configure is executed; do 
  8237.            not propagate configuration to subdirectories. 
  8238.  
  8239.  --rm 
  8240.            Remove files otherwise built during configuration. 
  8241.  
  8242.  --target=target 
  8243.            Configure GDB for cross-debugging programs running on the specified 
  8244.            target.  Without this option, GDB is configured to debug programs 
  8245.            that run on the same machine (host) as GDB itself. 
  8246.  
  8247.            There is no convenient way to generate a list of all available 
  8248.            targets. 
  8249.  
  8250.  host ... 
  8251.            Configure GDB to run on the specified host. 
  8252.  
  8253.            There is no convenient way to generate a list of all available 
  8254.            hosts. 
  8255.  
  8256.  configure accepts other options, for compatibility with configuring other gnu 
  8257.  tools recursively; but these are the only options that affect GDB or its 
  8258.  supporting libraries. 
  8259.  
  8260.  
  8261. ΓòÉΓòÉΓòÉ 25. Index ΓòÉΓòÉΓòÉ
  8262.  
  8263. Sorry, no cp index 
  8264.  
  8265.  
  8266. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  8267.  
  8268. `b' cannot be used because these format letters are also used with the x 
  8269. command, where `b' stands for ``byte''; see Examining memory.
  8270.  
  8271.  
  8272. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  8273.  
  8274. This is a way of removing one word from the stack, on machines where stacks 
  8275. grow downward in memory (most machines, nowadays).  This assumes that the 
  8276. innermost stack frame is selected; setting $sp is not allowed when other stack 
  8277. frames are selected.  To pop entire frames off the stack, regardless of machine 
  8278. architecture, use return; see Returning from a function.
  8279.  
  8280.  
  8281. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  8282.  
  8283. If you choose a port number that conflicts with another service, gdbserver 
  8284. prints an error message and exits.
  8285.  
  8286.  
  8287. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  8288.  
  8289. In `gdb-4.16/gdb/refcard.ps' of the version 4.16